Pārlūkot izejas kodu

allow freeing of NULL pointer to behave like standard free() function

The memory functions provided to openssl needs to behave like standard
memory functions, i.e. free(). Therefore, ser_free must accept NULL
pointers, see: http://openssl.6102.n7.nabble.com/Custom-free-routine-is-invoked-with-NULL-argument-in-openssl-1-0-1-td25937.html
As shm_free() aborts on null pointers, we have to check for null pointer
here in the wrapper function.
Klaus Darilion 13 gadi atpakaļ
vecāks
revīzija
7c37f8d4dc
1 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 9 1
      modules/tls/tls_init.c

+ 9 - 1
modules/tls/tls_init.c

@@ -295,7 +295,15 @@ static void* ser_realloc(void *ptr, size_t size)
 
 static void ser_free(void *ptr)
 {
-	shm_free(ptr);
+	/* The memory functions provided to openssl needs to behave like standard
+	 * memory functions, i.e. free(). Therefore, ser_free must accept NULL
+	 * pointers, see: http://openssl.6102.n7.nabble.com/Custom-free-routine-is-invoked-with-NULL-argument-in-openssl-1-0-1-td25937.html
+	 * As shm_free() aborts on null pointers, we have to check for null pointer
+	 * here in the wrapper function.
+	 */
+	if (ptr) {
+		shm_free(ptr);
+	}
 }