Browse code

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 authored on 07/11/2012 13:55:55
Showing 1 changed files
... ...
@@ -295,7 +295,15 @@ static void* ser_realloc(void *ptr, size_t size)
295 295
 
296 296
 static void ser_free(void *ptr)
297 297
 {
298
-	shm_free(ptr);
298
+	/* The memory functions provided to openssl needs to behave like standard
299
+	 * memory functions, i.e. free(). Therefore, ser_free must accept NULL
300
+	 * pointers, see: http://openssl.6102.n7.nabble.com/Custom-free-routine-is-invoked-with-NULL-argument-in-openssl-1-0-1-td25937.html
301
+	 * As shm_free() aborts on null pointers, we have to check for null pointer
302
+	 * here in the wrapper function.
303
+	 */
304
+	if (ptr) {
305
+		shm_free(ptr);
306
+	}
299 307
 }
300 308
 
301 309