From: borutr Date: Sun, 7 Mar 2004 19:41:59 +0000 (+0000) Subject: * support/Util/findme.c: alloca() replaced with malloc()/free() pair X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=0c2f734aa71a71774c9d1ef1579f785112008332;p=fw%2Fsdcc * support/Util/findme.c: alloca() replaced with malloc()/free() pair git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3252 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 9ff314de..523c4c12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-03-07 Borut Razem + + * support/Util/findme.c: alloca() replaced with malloc()/free() pair + 2004-03-06 Vangelis Rokas * src/pic16/ralloc.c (pic16_genPackRegisters): reverted to old diff --git a/support/Util/findme.c b/support/Util/findme.c index a950e500..45c63528 100644 --- a/support/Util/findme.c +++ b/support/Util/findme.c @@ -4,7 +4,9 @@ /* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING file accompanying popt source distributions, available from - ftp://ftp.rpm.org/pub/rpm/dist. */ + ftp://ftp.rpm.org/pub/rpm/dist. + + alloca replaced with malloc()/free() pair */ #include "system.h" #include "findme.h" @@ -22,7 +24,8 @@ const char * findProgramPath(const char * argv0) { if (path == NULL) return NULL; - start = pathbuf = alloca(strlen(path) + 1); + start = pathbuf = malloc(strlen(path) + 1); + if (pathbuf == NULL) return NULL; buf = malloc(strlen(path) + strlen(argv0) + sizeof("/")); if (buf == NULL) return NULL; /* XXX can't happen */ strcpy(pathbuf, path); @@ -34,8 +37,10 @@ const char * findProgramPath(const char * argv0) { *chptr = '\0'; sprintf(buf, "%s/%s", start, argv0); - if (!access(buf, X_OK)) + if (!access(buf, X_OK)) { + free(pathbuf); return buf; + } if (chptr) start = chptr + 1; @@ -45,6 +50,7 @@ const char * findProgramPath(const char * argv0) { /*@=branchstate@*/ free(buf); + free(pathbuf); return NULL; }