diff options
-rw-r--r-- | src/data/mediadata.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/data/mediadata.c b/src/data/mediadata.c index eb0ae3a..44663ec 100644 --- a/src/data/mediadata.c +++ b/src/data/mediadata.c @@ -248,18 +248,18 @@ static char *_get_genre(app_media_info *info) return strdup(genre); } -static void _get_place_string(app_media_info *info, char **city, char **country) +static void _get_place_string(const char *src, char **city, char **country) { char str[64]; char *p, *tmp; - if (!info->location_tag) { + if (!src) { *city = strdup(STR_PLACE_UNKNOWN); *country = strdup(STR_PLACE_UNKNOWN); return; } - strcpy(str, info->location_tag); + strcpy(str, src); p = strtok_r(str, "/", &tmp); if (!p) @@ -428,11 +428,13 @@ static int _compare_cb_place(const void *data1, const void *data2) if (!info1 || !info2) return -1; - _get_place_string(info1, &city1, &country1); - _get_place_string(info2, &city2, &country2); + _get_place_string(info1->location_tag, &city1, &country1); + _get_place_string(info2->location_tag, &city2, &country2); - if (!city1 || !city2 || !country1 || !country2) - return -1; + if (!city1 || !city2 || !country1 || !country2) { + r = -1; + goto ret; + } r = strcmp(country1, country2); if (!r) @@ -445,6 +447,7 @@ static int _compare_cb_place(const void *data1, const void *data2) r = -1; } +ret: free(city1); free(city2); free(country1); |