mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
logging: Resolve mem leak in virLogDaemonPreExecRestart
Initialize and free @magic since virJSONValueObjectAppendString does not free it for us eventually. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ff6f8a6be0
commit
232687f6ce
@ -508,7 +508,7 @@ virLogDaemonPreExecRestart(const char *state_file,
|
|||||||
virJSONValuePtr child;
|
virJSONValuePtr child;
|
||||||
char *state = NULL;
|
char *state = NULL;
|
||||||
virJSONValuePtr object = virJSONValueNewObject();
|
virJSONValuePtr object = virJSONValueNewObject();
|
||||||
char *magic;
|
char *magic = NULL;
|
||||||
|
|
||||||
VIR_DEBUG("Running pre-restart exec");
|
VIR_DEBUG("Running pre-restart exec");
|
||||||
|
|
||||||
@ -523,10 +523,8 @@ virLogDaemonPreExecRestart(const char *state_file,
|
|||||||
if (!(magic = virLogDaemonGetExecRestartMagic()))
|
if (!(magic = virLogDaemonGetExecRestartMagic()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virJSONValueObjectAppendString(object, "magic", magic) < 0) {
|
if (virJSONValueObjectAppendString(object, "magic", magic) < 0)
|
||||||
VIR_FREE(magic);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(child = virLogHandlerPreExecRestart(logDaemon->handler)))
|
if (!(child = virLogHandlerPreExecRestart(logDaemon->handler)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -559,6 +557,7 @@ virLogDaemonPreExecRestart(const char *state_file,
|
|||||||
abort(); /* This should be impossible to reach */
|
abort(); /* This should be impossible to reach */
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(magic);
|
||||||
VIR_FREE(state);
|
VIR_FREE(state);
|
||||||
virJSONValueFree(object);
|
virJSONValueFree(object);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user