[fix] calloc instead of malloc when performing initialization on structs that may fail halfway and need to clean up while partially initialized (calloc will set all the bytes to zero so the member pointers are NULL instead of garbage memory)
This commit is contained in:
@@ -51,7 +51,7 @@ numex_table_t *numex_table_init(void) {
|
||||
numex_table_t *numex_table = get_numex_table();
|
||||
|
||||
if (numex_table == NULL) {
|
||||
numex_table = malloc(sizeof(numex_table_t));
|
||||
numex_table = calloc(1, sizeof(numex_table_t));
|
||||
|
||||
if (numex_table == NULL) return NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user