From c80f81c19958fa219500a150513f9b2a6ab55c35 Mon Sep 17 00:00:00 2001 From: grischka Date: Fri, 3 Apr 2009 20:52:24 +0200 Subject: [PATCH] tiny_libmaker: fix function array overflow --- win32/tools/tiny_libmaker.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/win32/tools/tiny_libmaker.c b/win32/tools/tiny_libmaker.c index efda78ad..d45ec704 100644 --- a/win32/tools/tiny_libmaker.c +++ b/win32/tools/tiny_libmaker.c @@ -203,8 +203,8 @@ int main(int argc, char **argv) return 2; } - funcmax = 1000; - afpos = realloc(NULL, funcmax); // 250 func + funcmax = 250; + afpos = realloc(NULL, funcmax * sizeof *afpos); // 250 func memcpy(&arhdro.ar_mode, "100666", 6); //iarg = 1; @@ -264,11 +264,11 @@ int main(int argc, char **argv) anames = realloc(anames, strpos+istrlen); strcpy(anames + strpos, strtab + sym->st_name); strpos += istrlen; - if (funccnt >= funcmax) { - afpos = realloc(NULL, funcmax+1000); // 250 func more - funcmax += 1000; + if (++funccnt >= funcmax) { + funcmax += 250; + afpos = realloc(afpos, funcmax * sizeof *afpos); // 250 func more } - afpos[++funccnt] = fpos; + afpos[funccnt] = fpos; } } }