cedric pushed a commit to branch master. http://git.enlightenment.org/core/elementary.git/commit/?id=f7f362d0417f3cea2f24b20d2a5474e1343136a6
commit f7f362d0417f3cea2f24b20d2a5474e1343136a6 Author: SungTaek Hong <sth253.h...@samsung.com> Date: Fri Mar 4 16:02:15 2016 -0800 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 <ced...@osg.samsung.com> --- src/lib/elm_map.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/lib/elm_map.c b/src/lib/elm_map.c index b88edac..3dc1111 100644 --- a/src/lib/elm_map.c +++ b/src/lib/elm_map.c @@ -2791,11 +2791,9 @@ _xml_route_dump_cb(void *data, snprintf(buf, length, "%s", value); if (dump->id == ROUTE_XML_DISTANCE) dump->distance = _elm_atof(buf); else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) - dump->description = strdup(buf); + dump->description = buf; else if (dump->id == ROUTE_XML_COORDINATES) - dump->coordinates = strdup(buf); - - free(buf); + dump->coordinates = buf; } break; @@ -2844,8 +2842,7 @@ _xml_name_dump_cb(void *data, if (!buf) return EINA_FALSE; snprintf(buf, length + 1, "%s", value); - if (dump->id == NAME_XML_NAME) dump->address = strdup(buf); - free(buf); + if (dump->id == NAME_XML_NAME) dump->address = buf; } break; @@ -2871,7 +2868,7 @@ _xml_name_dump_list_cb(void *data, { name = calloc(1, sizeof(Elm_Map_Name)); if (!name) return EINA_FALSE; - name->address = strdup(dump.address); + name->address = dump.address; name->lon = dump.lon; name->lat = dump.lat; name->wsd = name_list->wsd; @@ -2941,6 +2938,7 @@ _kml_parse(Elm_Map_Route *r) free(str[0]); free(str); } + free(dump.description); } else WRN("description is not found !"); @@ -2970,6 +2968,7 @@ _kml_parse(Elm_Map_Route *r) free(str[0]); free(str); } + free(dump.coordinates); } } } @@ -3011,7 +3010,7 @@ _name_parse(Elm_Map_Name *n) if (dump.address) { INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address); - n->address = strdup(dump.address); + n->address = dump.address; } n->lon = dump.lon; n->lat = dump.lat; --