mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00: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:
parent
1f66001c69
commit
a8412f868b
@ -589,7 +589,10 @@ virConfParseComment(virConfParserCtxtPtr ctxt)
|
|||||||
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
|
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
|
||||||
if (VIR_STRNDUP(comm, base, ctxt->cur - base) < 0)
|
if (VIR_STRNDUP(comm, base, ctxt->cur - base) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
virConfAddEntry(ctxt->conf, NULL, NULL, comm);
|
if (virConfAddEntry(ctxt->conf, NULL, NULL, comm) == NULL) {
|
||||||
|
VIR_FREE(comm);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user