diff options
author | Diogo Ferreira <defer@cyngn.com> | 2016-09-07 15:40:34 +0200 |
---|---|---|
committer | Unpublished <unpublished2@gmx.net> | 2017-01-23 17:38:31 +0100 |
commit | ab9074c15e40e62db1842b596e8e16d972a6a231 (patch) | |
tree | f05688d8ab62c81e9101e88e8d3f9a54916e4a10 | |
parent | f8fddb48bbe167fc62e188a6585644b6ac2976f9 (diff) | |
download | android_system_extras_su-ab9074c15e40e62db1842b596e8e16d972a6a231.tar.gz android_system_extras_su-ab9074c15e40e62db1842b596e8e16d972a6a231.tar.bz2 android_system_extras_su-ab9074c15e40e62db1842b596e8e16d972a6a231.zip |
su: utils: Stop leaking a string
get_property is leaking a copy of 'data' on every call, free it when
we're done.
Change-Id: I5bbc2ae314038f3d56e7bd9b010eca6d173deb37
-rw-r--r-- | utils.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -58,7 +58,9 @@ int get_property(const char *data, char *found, const char *searchkey, const cha char *key, *value, *eol, *sol, *tmp; if (data == NULL) goto defval; int matched = 0; - sol = strdup(data); + char *dup = strdup(data); + + sol = dup; while((eol = strchr(sol, '\n'))) { key = sol; *eol++ = 0; @@ -82,6 +84,7 @@ int get_property(const char *data, char *found, const char *searchkey, const cha break; } } + free(dup); int len; if (matched) { len = strlen(value); |