mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
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 <berrange@redhat.com>
This commit is contained in:
+4
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user