summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-11-27 09:28:42 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-11-27 09:28:42 -0600
commita8b071dbd5d142b924861cf5508e84a828302fb4 (patch)
treebe4d67c8022e745a94507fc7a0cab9f6bf95dd17 /tools
parent3a8566b7966c6da0849792c3959900d9de9cb824 (diff)
downloadrtems-a8b071dbd5d142b924861cf5508e84a828302fb4.tar.bz2
rtems-bin2c.c: Fix free() of altered pointer
Diffstat (limited to 'tools')
-rw-r--r--tools/build/rtems-bin2c.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/build/rtems-bin2c.c b/tools/build/rtems-bin2c.c
index fc0381a259..391c25901f 100644
--- a/tools/build/rtems-bin2c.c
+++ b/tools/build/rtems-bin2c.c
@@ -119,8 +119,8 @@ void process(const char *ifname, const char *ofname)
}
/* find basename */
- char *ifbasename = strdup(ifname);
- if ( ifbasename == NULL ) {
+ char *ifbasename_to_free = strdup(ifname);
+ if ( ifbasename_to_free == NULL ) {
fprintf(stderr, "cannot allocate memory\n" );
fclose(ifile);
if ( createC ) { fclose(ocfile); }
@@ -128,7 +128,8 @@ void process(const char *ifname, const char *ofname)
exit(1);
}
- ifbasename = basename(ifbasename);
+ char *ifbasename;
+ ifbasename = basename(ifbasename_to_free);
strcpy(buf, ifbasename);
for (p = buf; *p != '\0'; ++p) {
@@ -252,7 +253,7 @@ void process(const char *ifname, const char *ofname)
fclose(ifile);
if ( createC ) { fclose(ocfile); }
if ( createH ) { fclose(ohfile); }
- free(ifbasename);
+ free(ifbasename_to_free);
}
void usage(void)