test_conf: Resolve Coverity RESOURCE_LEAK

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>
This commit is contained in:
Wang Rui 2014-09-01 20:08:04 +08:00 committed by John Ferlan
parent cd2d7c6c3a
commit 89060bd90e

View File

@ -11,7 +11,7 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret, exit_code = EXIT_FAILURE; int ret, exit_code = EXIT_FAILURE;
virConfPtr conf; virConfPtr conf = NULL;
int len = 10000; int len = 10000;
char *buffer = NULL; char *buffer = NULL;
@ -34,7 +34,6 @@ int main(int argc, char **argv)
fprintf(stderr, "Failed to serialize %s back\n", argv[1]); fprintf(stderr, "Failed to serialize %s back\n", argv[1]);
goto cleanup; goto cleanup;
} }
virConfFree(conf);
if (fwrite(buffer, 1, len, stdout) != len) { if (fwrite(buffer, 1, len, stdout) != len) {
fprintf(stderr, "Write failed: %s\n", strerror(errno)); fprintf(stderr, "Write failed: %s\n", strerror(errno));
goto cleanup; goto cleanup;
@ -44,5 +43,6 @@ int main(int argc, char **argv)
cleanup: cleanup:
VIR_FREE(buffer); VIR_FREE(buffer);
virConfFree(conf);
return exit_code; return exit_code;
} }