my_malloc returns NULL when no memory is available instead of segfaulting
@@ -99,11 +99,16 @@ void *my_malloc_block(protoop_plugin_t *p, unsigned int size) {
} else {
mp->next = NULL;
}
+ }
+
+ if (ret) {
+ *((uint64_t *)ret) = MAGIC_NUMBER;
+ ret += 8;
} else {
printf("Out of memory!\n");
}
- *((uint64_t *)ret) = MAGIC_NUMBER;
- return ret + 8;
+
+ return ret;
}
void *my_malloc_dbg(picoquic_cnx_t *cnx, unsigned int size, char *file, int line) {
