From 6e5e4496d7a87f014e6d281639d60222aa45d42a Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 19 Jun 2020 16:19:42 +0200 Subject: [PATCH] headerGetStringArrayEntry: add missing terminator --- src/rpmfunctions.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpmfunctions.c b/src/rpmfunctions.c index f2fcb67..bdb297f 100644 --- a/src/rpmfunctions.c +++ b/src/rpmfunctions.c @@ -189,13 +189,15 @@ headerGetStringArrayEntry(Header h, const int tag, int* count) if (headerGet(h, tag, td, HEADERGET_MINMEM) && rpmtdType(td) == RPM_STRING_ARRAY_TYPE && rpmtdCount(td) >= 1) { *count = rpmtdCount(td); if (*count > 0) { - st = malloc(sizeof(char*) * *count); + st = malloc(sizeof(char*) * (*count + 1)); const char* str; rpmtdInit(td); while ((str = rpmtdNextString(td))) { st[i] = strdup(str); i++; } + // Terminator + st[i] = NULL; rpmtdFree(td); } }