From e7d5739ce7fd25b759b97cf93c5a1fd6b1a87e9d Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sun, 23 Aug 2009 17:40:29 +0000 Subject: [PATCH] Fixed bug #27078: Possible memory leak in pppInit() --- CHANGELOG | 3 +++ src/netif/ppp/ppp.c | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e85ab3f9..53d83381 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,6 +25,9 @@ HISTORY ++ Bugfixes: + 2009-08-23 Simon Goldschmidt + * ppp.c: bug #27078: Possible memory leak in pppInit() + 2009-08-23 Simon Goldschmidt * netdb.c, dns.c: bug #26657: DNS, if host name is "localhost", result is error. diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 5b2aa783..b3d6eb2a 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -395,13 +395,17 @@ pppInit(void) magicInit(); + subnetMask = htonl(0xffffff00); + for (i = 0; i < NUM_PPP; i++) { pppControl[i].openFlag = 0; - subnetMask = htonl(0xffffff00); - outpacket_buf[i] = (u_char *)mem_malloc(PPP_MRU+PPP_HDRLEN); - if(!outpacket_buf[i]) { + if (!outpacket_buf[i]) { + for (j = 0; j < i; j++) { + /* deallocate all preceding buffers */ + mem_free(outpacket_buf[j]); + } return ERR_MEM; }