diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2014-06-21 12:30:41 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2014-06-21 12:45:57 +0200 |
commit | 597b2ec46a3708d50ab9620d5bb4fdbd19cf8a6c (patch) | |
tree | 2008804c4b64a105a8751abec2518f039a294609 /src/libpiano | |
parent | 4cd701c94150ed57b8492490dfea983fd9792f73 (diff) | |
download | pianobar-windows-597b2ec46a3708d50ab9620d5bb4fdbd19cf8a6c.tar.gz pianobar-windows-597b2ec46a3708d50ab9620d5bb4fdbd19cf8a6c.tar.bz2 pianobar-windows-597b2ec46a3708d50ab9620d5bb4fdbd19cf8a6c.zip |
piano: Fix segfault in GET_STATION_INFO response parser
Pandora added two new integer values to the feedback object, which
breaks the assumption that all values are arrays. Since we know the
names of the interesting keys (thumbsUp and thumbsDown) just use them
instead of iterating over all available keys.
Fixes #460.
Diffstat (limited to 'src/libpiano')
-rw-r--r-- | src/libpiano/response.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libpiano/response.c b/src/libpiano/response.c index fefa610..b530f3a 100644 --- a/src/libpiano/response.c +++ b/src/libpiano/response.c @@ -568,7 +568,14 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { json_object *feedback = json_object_object_get (result, "feedback"); if (feedback != NULL) { - json_object_object_foreach (feedback, key, val) { + static const char * const keys[] = {"thumbsUp", "thumbsDown"}; + for (size_t i = 0; i < sizeof (keys)/sizeof (*keys); i++) { + json_object * const val = json_object_object_get (feedback, + keys[i]); + if (val == NULL) { + continue; + } + assert (json_object_is_type (val, json_type_array)); for (int i = 0; i < json_object_array_length (val); i++) { json_object *s = json_object_array_get_idx (val, i); PianoSong_t *feedbackSong; |