summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobert_ch_chou <robert_ch_chou@acer.com.tw>2011-06-04 23:15:40 +0800
committerpeshovec <jlesev@gmail.com>2012-03-20 12:12:38 +0200
commit7cef7a6dea522f861dee467ff8f82953a8fb66da (patch)
treee46453811f85f267381d44f3bd6e0f15ebbe406c
parentc4cf52fd9b3eb72d951a42b236a8ad5a72626b99 (diff)
downloadandroid_external_dnsmasq-gingerbread.tar.gz
android_external_dnsmasq-gingerbread.tar.bz2
android_external_dnsmasq-gingerbread.zip
fix memory leakinggingerbread
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/
-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);
+ }
}
}