From c7b0f86815a74bff85594b8415bd369d965338a2 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 2 Aug 2022 09:51:50 -0700 Subject: [PATCH] cache: set the cache_table to NULL if empty Instead of realloc'ing to a size of 0, set the cache_table to NULL when removing the last element from it. --- libpkgconf/cache.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libpkgconf/cache.c b/libpkgconf/cache.c index 4fe2056..03ee0e4 100644 --- a/libpkgconf/cache.c +++ b/libpkgconf/cache.c @@ -186,8 +186,11 @@ pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg) } client->cache_count--; - client->cache_table = pkgconf_reallocarray(client->cache_table, - client->cache_count, sizeof(void *)); + if (client->cache_count == 0) + client->cache_table = NULL; + else + client->cache_table = pkgconf_reallocarray(client->cache_table, + client->cache_count, sizeof(void *)); } /*