From: Marius Storm-Olsen Date: Fri, 21 Aug 2009 13:30:33 GMT Subject: [PATCH 01/14] Fix non-constant array creation Message-ID: <6283b3e1775f43c6fc07e5047f9c99acdc27bc8f.1250860247.git.mstormo@gmail.com> In-Reply-To: MSVC doesn't munge the non-constant expression, so use xmalloc instead. Signed-off-by: Marius Storm-Olsen --- builtin-apply.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/builtin-apply.c b/builtin-apply.c index ae11b41..0f19965 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -1875,7 +1875,7 @@ static int match_fragment(struct image *img, size_t imgoff = 0; size_t preoff = 0; size_t postlen = postimage->len; - size_t imglen[preimage->nr]; + size_t *imglen = xmalloc(sizeof(size_t) * preimage->nr); for (i = 0; i < preimage->nr; i++) { size_t prelen = preimage->line[i].len; @@ -1901,6 +1901,7 @@ static int match_fragment(struct image *img, memcpy(fixed_buf, img->buf + try, imgoff); for (i = 0; i < preimage->nr; i++) preimage->line[i].len = imglen[i]; + free(imglen); /* * Update the preimage buffer and the postimage context lines. -- 1.6.3.msysgit.0.18.gef407