Francois Perrad 10 lat temu
rodzic
commit
970ce686e5
2 zmienionych plików z 2 dodań i 0 usunięć
  1. 1 0
      tests/test65.c
  2. 1 0
      tests/test83.c

+ 1 - 0
tests/test65.c

@@ -33,6 +33,7 @@ static void add_to_cache(char *key, char *value)
 {
     struct CacheEntry *entry, *tmp_entry;
     entry = malloc(sizeof(struct CacheEntry));
+    if (entry == NULL) exit(-1);
     entry->key = strdup(key);
     entry->value = strdup(value);
     HASH_ADD_KEYPTR(hh, cache, entry->key, strlen(entry->key), entry);

+ 1 - 0
tests/test83.c

@@ -32,6 +32,7 @@ int main(int argc, char*argv[]) {
         if (person != NULL) {
             printf("found %s (id %d)\n", person->first_name, person->id);
             new_person  = malloc(sizeof(person_t));
+            if (new_person == NULL) exit(-1);
             memcpy(new_person, person, sizeof(person_t));
             new_person->id = person->id*10;
             HASH_REPLACE_STR(people,first_name,new_person,tmp);