[sr-dev] git:3.3: allow freeing of NULL pointer to behave like standard free() function

Klaus Darilion klaus.mailinglists at pernau.at
Wed Nov 7 15:11:19 CET 2012


Module: sip-router
Branch: 3.3
Commit: 020acff35f8e9dfa62aba8678a781a0f7bbb110b
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=020acff35f8e9dfa62aba8678a781a0f7bbb110b

Author: Klaus Darilion <klaus.mailinglists at pernau.at>
Committer: Klaus Darilion <klaus.mailinglists at pernau.at>
Date:   Wed Nov  7 13:55:55 2012 +0000

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.
(cherry picked from commit 7c37f8d4dc311c64c12e0b03b5e312892f9d886c)

---

 modules/tls/tls_init.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/modules/tls/tls_init.c b/modules/tls/tls_init.c
index e409b5e..b629afa 100644
--- a/modules/tls/tls_init.c
+++ b/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);
+	}
 }
 
 




More information about the sr-dev mailing list