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>
This commit is contained in:
SungTaek Hong 2016-03-04 16:02:15 -08:00 committed by Cedric BAIL
parent 69785a72e4
commit 2222590f1d
1 changed files with 7 additions and 8 deletions

View File

@ -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;