From 2f311c562d87c0bf95d27709e82afd196c2bff28 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Tue, 3 Mar 2015 11:30:12 +0900 Subject: [PATCH] Fix the array allocation --- src/fcstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fcstat.c b/src/fcstat.c index d444bf9..1734fa4 100644 --- a/src/fcstat.c +++ b/src/fcstat.c @@ -219,7 +219,7 @@ FcScandir (const char *dirp, dentlen = ((dentlen + ALIGNOF_VOID_P - 1) & ~(ALIGNOF_VOID_P - 1)); p = (struct dirent *) malloc (dentlen); memcpy (p, dent, dentlen); - if (n >= lsize) + if ((n + 1) >= lsize) { lsize += 128; dlp = (struct dirent **) realloc (dlist, sizeof (struct dirent *) * lsize);