headerGetStringArrayEntry: add missing terminator

This commit is contained in:
Silvan Calarco 2020-06-19 16:19:42 +02:00
parent 8836c8f87b
commit 6e5e4496d7

View File

@ -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) { if (headerGet(h, tag, td, HEADERGET_MINMEM) && rpmtdType(td) == RPM_STRING_ARRAY_TYPE && rpmtdCount(td) >= 1) {
*count = rpmtdCount(td); *count = rpmtdCount(td);
if (*count > 0) { if (*count > 0) {
st = malloc(sizeof(char*) * *count); st = malloc(sizeof(char*) * (*count + 1));
const char* str; const char* str;
rpmtdInit(td); rpmtdInit(td);
while ((str = rpmtdNextString(td))) { while ((str = rpmtdNextString(td))) {
st[i] = strdup(str); st[i] = strdup(str);
i++; i++;
} }
// Terminator
st[i] = NULL;
rpmtdFree(td); rpmtdFree(td);
} }
} }