提交 a01e6721 编写于 作者: S Stefan Berger 提交者: Stefan Berger

tests: fix resource leak

Error: RESOURCE_LEAK:
/libvirt/tests/qemuxml2argvtest.c:47:
alloc_arg: Calling allocation function "virAlloc" on "ret".
/libvirt/src/util/memory.c:101:
alloc_fn: Storage is returned from allocation function "calloc".
/libvirt/src/util/memory.c:101:
var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/libvirt/tests/qemuxml2argvtest.c:54:
leaked_storage: Variable "ret" going out of scope leaks the storage it points to.
上级 c0774482
......@@ -50,8 +50,10 @@ fakeSecretLookupByUsage(virConnectPtr conn,
ret->magic = VIR_SECRET_MAGIC;
ret->refs = 1;
ret->usageID = strdup(usageID);
if (!ret->usageID)
if (!ret->usageID) {
VIR_FREE(ret);
return NULL;
}
ret->conn = conn;
conn->refs++;
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册