summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-10-14 00:19:45 (GMT)
committerJehun Lim <jehun.lim@samsung.com>2015-10-14 01:06:52 (GMT)
commitd01b4a64751f98c57702b38063923956e0b96ac4 (patch)
treee3b27a8227a5b004353cc8d86f1291468c455566
parent571b829d3fceb33da210d6f7debfa50f1623c4f3 (diff)
downloadair_mediahub-d01b4a64751f98c57702b38063923956e0b96ac4.zip
air_mediahub-d01b4a64751f98c57702b38063923956e0b96ac4.tar.gz
air_mediahub-d01b4a64751f98c57702b38063923956e0b96ac4.tar.bz2
mediadata: fix memory leak (prevent: 486273, 486274, 486275, 486277)refs/changes/84/49484/1
Change-Id: I94ae9e4bb0107fe347b64a50a932d093cad486bd Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--src/data/mediadata.c17
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);