From 3bce852a286b5647291b86c079ff71d7254d342a Mon Sep 17 00:00:00 2001 From: ckolivas Date: Sat, 24 Jan 2015 09:44:43 +1100 Subject: [PATCH] Null the source pointer that calls jsonp_free generically as a sanity precaution. --- src/jansson-2.6/src/jansson_private.h | 4 +++- src/jansson-2.6/src/memory.c | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/jansson-2.6/src/jansson_private.h b/src/jansson-2.6/src/jansson_private.h index 3ca4dffa..9de9c1eb 100644 --- a/src/jansson-2.6/src/jansson_private.h +++ b/src/jansson-2.6/src/jansson_private.h @@ -81,7 +81,9 @@ int jsonp_dtostr(char *buffer, size_t size, double value); /* Wrappers for custom memory functions */ void* jsonp_malloc(size_t size); -void jsonp_free(void *ptr); +void _jsonp_free(void **ptr); +#define jsonp_free(ptr) _jsonp_free((void *)&(ptr)) + char *jsonp_strndup(const char *str, size_t length); char *jsonp_strdup(const char *str); char *jsonp_eolstrdup(const char *str); diff --git a/src/jansson-2.6/src/memory.c b/src/jansson-2.6/src/memory.c index 0be24380..5a00bafc 100644 --- a/src/jansson-2.6/src/memory.c +++ b/src/jansson-2.6/src/memory.c @@ -25,12 +25,13 @@ void *jsonp_malloc(size_t size) return (*do_malloc)(size); } -void jsonp_free(void *ptr) +void _jsonp_free(void **ptr) { - if(!ptr) + if(!*ptr) return; - (*do_free)(ptr); + (*do_free)(*ptr); + *ptr = NULL; } char *jsonp_strdup(const char *str)