aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/support
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-04-13 01:35:42 +0200
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-04-13 01:35:42 +0200
commit23e4baefc2669c271f78402f5e9523d9f60a4cfe (patch)
treee71911eaf320c84b6a5ac4f4cda508b1e4b853ce /src/core/lib/support
parentb71bf8eb214894d11db77eae78a9abb8c4cebf44 (diff)
Enforcing undefined behavior of malloc.
Diffstat (limited to 'src/core/lib/support')
-rw-r--r--src/core/lib/support/alloc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/core/lib/support/alloc.c b/src/core/lib/support/alloc.c
index 020917f79c..618c3f6acd 100644
--- a/src/core/lib/support/alloc.c
+++ b/src/core/lib/support/alloc.c
@@ -53,6 +53,7 @@ void gpr_set_allocation_functions(gpr_allocation_functions functions) {
void *gpr_malloc(size_t size) {
void *p;
+ if (size == 0) return NULL;
GPR_TIMER_BEGIN("gpr_malloc", 0);
p = g_alloc_functions.malloc_fn(size);
if (!p) {
@@ -69,6 +70,7 @@ void gpr_free(void *p) {
}
void *gpr_realloc(void *p, size_t size) {
+ if ((size == 0) && (p == NULL)) return NULL;
GPR_TIMER_BEGIN("gpr_realloc", 0);
p = g_alloc_functions.realloc_fn(p, size);
if (!p) {