If the condition 'ret < 0' is true, the code will jump to
'cleanup' and 'conf' won't be freed.
Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
int main(int argc, char **argv)
{
int ret, exit_code = EXIT_FAILURE;
- virConfPtr conf;
+ virConfPtr conf = NULL;
int len = 10000;
char *buffer = NULL;
fprintf(stderr, "Failed to serialize %s back\n", argv[1]);
goto cleanup;
}
- virConfFree(conf);
if (fwrite(buffer, 1, len, stdout) != len) {
fprintf(stderr, "Write failed: %s\n", strerror(errno));
goto cleanup;
cleanup:
VIR_FREE(buffer);
+ virConfFree(conf);
return exit_code;
}