test: fix coverity 1470559: resource leak
authorPauli <ppzgs1@gmail.com>
Thu, 18 Mar 2021 02:54:28 +0000 (12:54 +1000)
committerPauli <ppzgs1@gmail.com>
Sat, 20 Mar 2021 00:08:00 +0000 (10:08 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14596)

test/moduleloadtest.c

index 915343f055d7034b4da8629f531f84f21acf1b8e..2ad0dac75249af3d8edb4ddecfccf1757467abb1 100644 (file)
@@ -23,10 +23,14 @@ static int test_load(const char *path, const char *symbol)
 #ifdef SD_INIT
     SD sd = SD_INIT;
     SD_SYM sym;
-
-    return sd_load(path, &sd, SD_MODULE)
-        && (symbol == NULL || sd_sym(sd, symbol, &sym))
-        && sd_close(sd);
+    int ret;
+
+    if (!sd_load(path, &sd, SD_MODULE))
+        return 0;
+    ret = symbol == NULL || sd_sym(sd, symbol, &sym);
+    if (!sd_close(sd))
+        ret = 0;
+    return ret;
 #else
     fprintf(stderr, "No dynamic loader\n");
     return 0;