[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:
@@ -284,7 +284,7 @@ phrase_t search_address_dictionaries_suffix(char *str, size_t len, char *lang) {
|
||||
bool address_dictionary_init(void) {
|
||||
if (address_dict != NULL) return false;
|
||||
|
||||
address_dict = malloc(sizeof(address_dictionary_t));
|
||||
address_dict = calloc(1, sizeof(address_dictionary_t));
|
||||
if (address_dict == NULL) return false;
|
||||
|
||||
address_dict->canonical = cstring_array_new();
|
||||
|
||||
Reference in New Issue
Block a user