]> git.gag.com Git - fw/sdcc/commitdiff
* support/Util/findme.c: alloca() replaced with malloc()/free() pair
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 7 Mar 2004 19:41:59 +0000 (19:41 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 7 Mar 2004 19:41:59 +0000 (19:41 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3252 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
support/Util/findme.c

index 9ff314dec0414ec33a5b1166ae8727f1e0c86279..523c4c12596c0ee7ae8dc26122ae0247d6c83e90 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-03-07  Borut Razem <borut.razem AT siol.net>
+
+       * support/Util/findme.c: alloca() replaced with malloc()/free() pair
+
 2004-03-06 Vangelis Rokas <vrokas AT otenet.gr>
 
        * src/pic16/ralloc.c (pic16_genPackRegisters): reverted to old
index a950e50018b1827ecf346c87278f094b1e5acb7c..45c6352825d8474c0e9e9833e892e7e9bd296b79 100644 (file)
@@ -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;
 }