Просмотр исходного кода

icmap: icmap_init_r() leaks if trie_create() fails

Thanks to Coverity for finding this

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Christine Caulfield 5 лет назад
Родитель
Сommit
c631951ef5
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      exec/icmap.c

+ 3 - 1
exec/icmap.c

@@ -195,8 +195,10 @@ cs_error_t icmap_init_r(icmap_map_t *result)
 	}
 	}
 
 
         (*result)->qb_map = qb_trie_create();
         (*result)->qb_map = qb_trie_create();
-	if ((*result)->qb_map == NULL)
+	if ((*result)->qb_map == NULL) {
+		free(*result);
 		return (CS_ERR_INIT);
 		return (CS_ERR_INIT);
+	}
 
 
 	err = qb_map_notify_add((*result)->qb_map, NULL, icmap_map_free_cb, QB_MAP_NOTIFY_FREE, NULL);
 	err = qb_map_notify_add((*result)->qb_map, NULL, icmap_map_free_cb, QB_MAP_NOTIFY_FREE, NULL);