fix: exception when artist is empty (#16)

Co-authored-by: wshon <me@wshon.com>
This commit is contained in:
wshon 2024-03-24 09:01:38 +08:00 committed by GitHub
parent d73e8c603c
commit ae08d4475c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 4 deletions

View File

@ -94,12 +94,18 @@ NeteaseMusicMetadata::NeteaseMusicMetadata(cJSON *raw)
artistLen = cJSON_GetArraySize(swap);
i = 0;
for (i = 0; i < artistLen - 1; i++)
for (i = 0; i < artistLen; i++)
{
auto artist = cJSON_GetArrayItem(swap, i);
if (cJSON_GetArraySize(artist) > 0)
{
if (!mArtist.empty())
{
mArtist += std::string(cJSON_GetStringValue(cJSON_GetArrayItem(cJSON_GetArrayItem(swap, i), 0)));
mArtist += "/";
}
mArtist += std::string(cJSON_GetStringValue(cJSON_GetArrayItem(cJSON_GetArrayItem(swap, i), 0)));
mArtist += std::string(cJSON_GetStringValue(cJSON_GetArrayItem(artist, 0)));
}
}
}
swap = cJSON_GetObjectItem(raw, "bitrate");