Skip to content

Commit

Permalink
Fix crash with no songs
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed Jul 8, 2023
1 parent bfa3812 commit 6615f61
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/src/lyrics/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ void lib::lrc::api::search(const std::string &query,
return;
}

const auto songs = json.at("result").at("songs");
const auto &result = json.at("result");
if (!result.contains("songs"))
{
callback(lib::result<std::vector<lib::lrc::search_result>>::fail("No results"));
return;
}

const auto &songs = result.at("songs");
if (!songs.is_array() || songs.empty())
{
callback(lib::result<std::vector<lib::lrc::search_result>>::fail("No lyrics found"));
Expand Down

0 comments on commit 6615f61

Please sign in to comment.