[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:
@@ -32,7 +32,7 @@ Constructors
|
||||
*/
|
||||
|
||||
static trie_t *trie_new_empty(uint8_t *alphabet, uint32_t alphabet_size) {
|
||||
trie_t *self = malloc(sizeof(trie_t));
|
||||
trie_t *self = calloc(1, sizeof(trie_t));
|
||||
if (!self)
|
||||
goto exit_no_malloc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user