Terminate strv with NULL
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 20 Dec 2011 05:09:58 +0000 (03:09 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 20 Dec 2011 05:27:50 +0000 (03:27 -0200)
libkmod/libkmod-elf.c

index 4438120..7bd73fc 100644 (file)
@@ -433,10 +433,11 @@ int kmod_elf_get_strings(const struct kmod_elf *elf, const char *section, char *
        if (strings[i - 1] != '\0')
                count++;
 
-       *array = a = malloc(size + 1 + sizeof(char *) * count);
+       *array = a = malloc(size + 1 + sizeof(char *) * (count + 1));
        if (*array == NULL)
                return -errno;
 
+       a[count] = NULL;
        itr = (char *)(a + count);
        last = 0;
        for (i = 0, count = 0; i < size; i++) {