From: Wouter Wijngaards Date: Fri, 6 May 2016 06:56:51 +0000 (+0000) Subject: - Fix memory leak in out-of-memory conditions of local zone add. X-Git-Tag: release-1.5.9rc1~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=455a6812044343785f3dfa4d0d86826fc1b6467c;p=thirdparty%2Funbound.git - Fix memory leak in out-of-memory conditions of local zone add. git-svn-id: file:///svn/unbound/trunk@3717 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index e349e84a0..bc84f0e51 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +6 May 2016: Wouter + - Fix memory leak in out-of-memory conditions of local zone add. + 29 April 2016: Wouter - Fix sldns with static checking fixes copied from getdns. diff --git a/services/localzone.c b/services/localzone.c index bc4eb4573..3c966243d 100644 --- a/services/localzone.c +++ b/services/localzone.c @@ -172,6 +172,7 @@ lz_enter_zone_dname(struct local_zones* zones, uint8_t* nm, size_t len, { struct local_zone* z = local_zone_create(nm, len, labs, t, c); if(!z) { + free(nm); log_err("out of memory"); return NULL; } @@ -1275,7 +1276,10 @@ struct local_zone* local_zones_add_zone(struct local_zones* zones, { /* create */ struct local_zone* z = local_zone_create(name, len, labs, tp, dclass); - if(!z) return NULL; + if(!z) { + free(name); + return NULL; + } lock_rw_wrlock(&z->lock); /* find the closest parent */