Browse Source

webservices: acoustid: fix null dereference in parse_artists

json_get_array() can return NULL if the key is not found. passing NULL
to parse_artists() caused a crash because it accessed artists->size
without checking.

This patch adds a check for NULL in parse_artists() to avoid the crash.

Fixes #29361

Signed-off-by: Abderhman Gamal <abderhmangamal246@gmail.com>
work/unnecessary-disc-string
Abderhman Gamal 4 months ago
committed by Steve Lhomme
parent
commit
ec9adb00d1
  1. 4
      modules/misc/webservices/acoustid.c

4
modules/misc/webservices/acoustid.c

@ -44,6 +44,7 @@ void acoustid_result_release( acoustid_result_t * r )
static void parse_artists( const struct json_array *artists, acoustid_mb_result_t *record )
{
assert( artists != NULL );
/* take only main */
if ( artists->size < 1)
return;
@ -78,7 +79,8 @@ static void parse_recordings( vlc_object_t *p_obj, const struct json_object *obj
}
const struct json_array *artists = json_get_array(&recordnode->object,
"artists");
parse_artists( artists, record );
if (artists != NULL)
parse_artists( artists, record );
msg_Dbg( p_obj, "recording %d title %s %36s %s", i, record->psz_title,
record->s_musicbrainz_id, record->psz_artist );
}

Loading…
Cancel
Save