Properly own the duplicated string
[openssl.git] / crypto / threads_pthread.c
index 2b32e14..edca77c 100644 (file)
@@ -58,8 +58,10 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
     if (lock == NULL)
         return NULL;
 
-    if (pthread_rwlock_init(lock, NULL) != 0)
+    if (pthread_rwlock_init(lock, NULL) != 0) {
+        OPENSSL_free(lock);
         return NULL;
+    }
 
     return lock;
 }