[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:
Al
2017-01-13 18:06:41 -05:00
parent 1398df1260
commit df89387b5c
13 changed files with 15 additions and 15 deletions

View File

@@ -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();