Skip to content
Snippets Groups Projects
Commit 23e4baef authored by Nicolas "Pixel" Noble's avatar Nicolas "Pixel" Noble
Browse files

Enforcing undefined behavior of malloc.

parent b71bf8eb
No related branches found
No related tags found
No related merge requests found
...@@ -53,6 +53,7 @@ void gpr_set_allocation_functions(gpr_allocation_functions functions) { ...@@ -53,6 +53,7 @@ void gpr_set_allocation_functions(gpr_allocation_functions functions) {
void *gpr_malloc(size_t size) { void *gpr_malloc(size_t size) {
void *p; void *p;
if (size == 0) return NULL;
GPR_TIMER_BEGIN("gpr_malloc", 0); GPR_TIMER_BEGIN("gpr_malloc", 0);
p = g_alloc_functions.malloc_fn(size); p = g_alloc_functions.malloc_fn(size);
if (!p) { if (!p) {
...@@ -69,6 +70,7 @@ void gpr_free(void *p) { ...@@ -69,6 +70,7 @@ void gpr_free(void *p) {
} }
void *gpr_realloc(void *p, size_t size) { void *gpr_realloc(void *p, size_t size) {
if ((size == 0) && (p == NULL)) return NULL;
GPR_TIMER_BEGIN("gpr_realloc", 0); GPR_TIMER_BEGIN("gpr_realloc", 0);
p = g_alloc_functions.realloc_fn(p, size); p = g_alloc_functions.realloc_fn(p, size);
if (!p) { if (!p) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment