summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Hung Chou <robert_ch_chou@acer.com.tw>2012-09-18 10:38:08 -0300
committerJoão Assad <jfassad@gmail.com>2012-09-18 10:38:08 -0300
commitc3a70a9536fd3a288a886d4e99618e1c70e48b22 (patch)
tree776de9e8a2f50d75a55d3f644554a53b3bea1213
parentf621afad94df46204c25fc2593a19d704d2637f5 (diff)
downloadandroid_external_dnsmasq-jellybean-stable.tar.gz
android_external_dnsmasq-jellybean-stable.tar.bz2
android_external_dnsmasq-jellybean-stable.zip
fix memory leakingjellybean-stablejellybean
There is a possible memory leaking when lo is allocated but the lo->name is not. In this case, we should free the lo and then return original change I475968bd570a113c9f61f02b974d57d1caaa0236 picked from: https://android-review.googlesource.com/#/c/23450/ as seen on: http://review.cyanogenmod.com/#/c/13782/ Change-Id: I21dd3267fa2521578d93f7b1a7bc2a6726de15ac
-rwxr-xr-xsrc/network.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/network.c b/src/network.c
index b0ffc6b..2dba31c 100755
--- a/src/network.c
+++ b/src/network.c
@@ -162,14 +162,17 @@ static int iface_allowed(struct irec **irecp, int if_index,
break;
}
- if (!lo &&
- (lo = whine_malloc(sizeof(struct iname))) &&
- (lo->name = whine_malloc(strlen(ifr.ifr_name)+1)))
- {
- strcpy(lo->name, ifr.ifr_name);
- lo->isloop = lo->used = 1;
- lo->next = daemon->if_names;
- daemon->if_names = lo;
+ if (!lo && (lo = whine_malloc(sizeof(struct iname))))
+ {
+ if ((lo->name = whine_malloc(strlen(ifr.ifr_name)+1)))
+ {
+ strcpy(lo->name, ifr.ifr_name);
+ lo->isloop = lo->used = 1;
+ lo->next = daemon->if_names;
+ daemon->if_names = lo;
+ } else {
+ free(lo);
+ }
}
}