]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Curl_polarsslthreadlock_thread_setup: clear array at init
authorDaniel Stenberg <daniel@haxx.se>
Tue, 18 Oct 2016 11:05:43 +0000 (13:05 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 18 Oct 2016 11:05:43 +0000 (13:05 +0200)
... since if it fails to init the entire array and then tries to clean
it up, it would attempt to work on an uninitialized pointer.

lib/vtls/polarssl_threadlock.c

index 3b0ebf88665917e0d8d456b7c0f030f64674f910..b1eb7b746a1da3c3af348e4d4fb41c8a9033c6f5 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 2013-2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2013-2016, Daniel Stenberg, <daniel@haxx.se>, et al.
  * Copyright (C) 2010, 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
  *
  * This software is licensed as described in the file COPYING, which
@@ -52,7 +52,7 @@ int Curl_polarsslthreadlock_thread_setup(void)
   int i;
   int ret;
 
-  mutex_buf = malloc(NUMT * sizeof(POLARSSL_MUTEX_T));
+  mutex_buf = calloc(NUMT * sizeof(POLARSSL_MUTEX_T), 1);
   if(!mutex_buf)
     return 0;     /* error, no number of threads defined */