coverity 1462548 Resource leak
[openssl.git] / crypto / info.c
index 8e674fc30a6b850c51cefa3a9c3b68648bb024d1..968184fceb819694f29e3666d70fffd2f15b2890 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -72,14 +72,15 @@ DEFINE_RUN_ONCE_STATIC(init_info_strings)
         do {                                                            \
             add_seeds_string(label "(");                                \
             {                                                           \
-                const char *dev[] = strlist;                            \
+                const char *dev[] =  { strlist, NULL };                 \
+                const char **p;                                         \
                 int first = 1;                                          \
                                                                         \
-                for (; *dev != NULL; dev++) {                           \
+                for (p = dev; *p != NULL; p++) {                        \
                     if (!first)                                         \
                         OPENSSL_strlcat(seeds, " ", sizeof(seeds));     \
                     first = 0;                                          \
-                    OPENSSL_strlcat(seeds, *dev, sizeof(seeds));        \
+                    OPENSSL_strlcat(seeds, *p, sizeof(seeds));          \
                 }                                                       \
             }                                                           \
             OPENSSL_strlcat(seeds, ")", sizeof(seeds));                 \
@@ -101,10 +102,10 @@ DEFINE_RUN_ONCE_STATIC(init_info_strings)
         add_seeds_string("getrandom-syscall");
 #endif
 #ifdef OPENSSL_RAND_SEED_DEVRANDOM
-        add_seeds_stringlist("random-device", { DEVRANDOM, NULL });
+        add_seeds_stringlist("random-device", DEVRANDOM);
 #endif
 #ifdef OPENSSL_RAND_SEED_EGD
-        add_seeds_stringlist("EGD", { DEVRANDOM_EGD, NULL });
+        add_seeds_stringlist("EGD", DEVRANDOM_EGD);
 #endif
 #ifdef OPENSSL_RAND_SEED_OS
         add_seeds_string("os-specific");