Skip to content

Commit

Permalink
Enforcing undefined behavior of malloc.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasnoble committed Apr 12, 2016
1 parent b71bf8e commit 23e4bae
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/lib/support/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 23e4bae

Please sign in to comment.