summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSungTaek Hong <sth253.hong@samsung.com>2016-03-04 16:02:15 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-03-04 16:14:37 -0800
commitf7f362d0417f3cea2f24b20d2a5474e1343136a6 (patch)
treee3bc1e28a052e609ac8e298dba6eb4259649f0e2
parent5087a8f94f71294a20b567fdc518cfadee13dd46 (diff)
map: fix memory leak
Summary: - in dump_cb buf is allocated by malloc() ->strdup() -> free. This is needless. - And buf allocated in dump_cb is strdup again. This may cause memory leak. Reviewers: Hermet, woohyun, cedric Reviewed By: cedric Differential Revision: https://phab.enlightenment.org/D3752 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/elm_map.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/lib/elm_map.c b/src/lib/elm_map.c
index b88edacf4..3dc1111f7 100644
--- a/src/lib/elm_map.c
+++ b/src/lib/elm_map.c
@@ -2791,11 +2791,9 @@ _xml_route_dump_cb(void *data,
2791 snprintf(buf, length, "%s", value); 2791 snprintf(buf, length, "%s", value);
2792 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = _elm_atof(buf); 2792 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = _elm_atof(buf);
2793 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) 2793 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION))
2794 dump->description = strdup(buf); 2794 dump->description = buf;
2795 else if (dump->id == ROUTE_XML_COORDINATES) 2795 else if (dump->id == ROUTE_XML_COORDINATES)
2796 dump->coordinates = strdup(buf); 2796 dump->coordinates = buf;
2797
2798 free(buf);
2799 } 2797 }
2800 break; 2798 break;
2801 2799
@@ -2844,8 +2842,7 @@ _xml_name_dump_cb(void *data,
2844 2842
2845 if (!buf) return EINA_FALSE; 2843 if (!buf) return EINA_FALSE;
2846 snprintf(buf, length + 1, "%s", value); 2844 snprintf(buf, length + 1, "%s", value);
2847 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf); 2845 if (dump->id == NAME_XML_NAME) dump->address = buf;
2848 free(buf);
2849 } 2846 }
2850 break; 2847 break;
2851 2848
@@ -2871,7 +2868,7 @@ _xml_name_dump_list_cb(void *data,
2871 { 2868 {
2872 name = calloc(1, sizeof(Elm_Map_Name)); 2869 name = calloc(1, sizeof(Elm_Map_Name));
2873 if (!name) return EINA_FALSE; 2870 if (!name) return EINA_FALSE;
2874 name->address = strdup(dump.address); 2871 name->address = dump.address;
2875 name->lon = dump.lon; 2872 name->lon = dump.lon;
2876 name->lat = dump.lat; 2873 name->lat = dump.lat;
2877 name->wsd = name_list->wsd; 2874 name->wsd = name_list->wsd;
@@ -2941,6 +2938,7 @@ _kml_parse(Elm_Map_Route *r)
2941 free(str[0]); 2938 free(str[0]);
2942 free(str); 2939 free(str);
2943 } 2940 }
2941 free(dump.description);
2944 } 2942 }
2945 else WRN("description is not found !"); 2943 else WRN("description is not found !");
2946 2944
@@ -2970,6 +2968,7 @@ _kml_parse(Elm_Map_Route *r)
2970 free(str[0]); 2968 free(str[0]);
2971 free(str); 2969 free(str);
2972 } 2970 }
2971 free(dump.coordinates);
2973 } 2972 }
2974 } 2973 }
2975} 2974}
@@ -3011,7 +3010,7 @@ _name_parse(Elm_Map_Name *n)
3011 if (dump.address) 3010 if (dump.address)
3012 { 3011 {
3013 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address); 3012 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
3014 n->address = strdup(dump.address); 3013 n->address = dump.address;
3015 } 3014 }
3016 n->lon = dump.lon; 3015 n->lon = dump.lon;
3017 n->lat = dump.lat; 3016 n->lat = dump.lat;