From: Daniel P. Berrange Date: Wed, 25 Sep 2013 10:32:07 +0000 (+0100) Subject: Fix leak of comment string if virConfAddEntry fails on OOM X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a8412f868b52b91cf3d40389588c28e733e953e3;p=libvirt.git Fix leak of comment string if virConfAddEntry fails on OOM The code parsing comments in config files called virConfAddEntry but did not check for failure. This caused the comment string to leak on OOM. Signed-off-by: Daniel P. Berrange --- diff --git a/src/util/virconf.c b/src/util/virconf.c index 9952f3fee0..e882d15075 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -589,7 +589,10 @@ virConfParseComment(virConfParserCtxtPtr ctxt) while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT; if (VIR_STRNDUP(comm, base, ctxt->cur - base) < 0) return -1; - virConfAddEntry(ctxt->conf, NULL, NULL, comm); + if (virConfAddEntry(ctxt->conf, NULL, NULL, comm) == NULL) { + VIR_FREE(comm); + return -1; + } return 0; }