[libvirt] [PATCH 2/3] tests: Resolve Coverity RESOURCE_LEAK

Wang Rui moon.wangrui at huawei.com
Thu Aug 28 10:20:57 UTC 2014


The 'lib' handle will be leaked if 'dlsym' condition fails.
So close the handle before return.

Signed-off-by: Wang Rui <moon.wangrui at huawei.com>
---
 tests/shunloadtest.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/shunloadtest.c b/tests/shunloadtest.c
index 499b1be..80f5351 100644
--- a/tests/shunloadtest.c
+++ b/tests/shunloadtest.c
@@ -114,6 +114,7 @@ int main(int argc ATTRIBUTE_UNUSED, char **argv)
     }
     if (!(startup = dlsym(lib, "shunloadStart"))) {
         fprintf(stderr, "Cannot find shunloadStart %s\n", dlerror());
+        dlclose(lib);
         return 1;
     }
 
-- 
1.7.12.4





More information about the libvir-list mailing list