From 3c9f58204e0e420713c2b7e8b555626b794a98cc Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 23 Apr 2002 18:52:39 +0000 Subject: [PATCH] Don't free(9) a pointer which has been modified. Chapeau de pointe: mux --- sys/amd64/amd64/autoconf.c | 13 +++++++------ sys/i386/i386/autoconf.c | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sys/amd64/amd64/autoconf.c b/sys/amd64/amd64/autoconf.c index 60b372525e32..85808d5b3ce9 100644 --- a/sys/amd64/amd64/autoconf.c +++ b/sys/amd64/amd64/autoconf.c @@ -290,31 +290,32 @@ hwaddr_to_sockaddr(char *ev, struct sockaddr_dl *sa) static int decode_nfshandle(char *ev, u_char *fh) { - u_char *cp; + u_char *cp, *ep; int len, val; - if ((cp = getenv(ev)) == NULL) + ep = cp = getenv(ev); + if (cp == NULL) return(0); if ((strlen(cp) < 2) || (*cp != 'X')) { - freeenv(cp); + freeenv(ep); return (0); } len = 0; cp++; for (;;) { if (*cp == 'X') { - freeenv(cp); + freeenv(ep); return(len); } if ((sscanf(cp, "%2x", &val) != 1) || (val > 0xff)) { - freeenv(cp); + freeenv(ep); return(0); } *(fh++) = val; len++; cp += 2; if (len > NFSX_V2FH) { - freeenv(cp); + freeenv(ep); return(0); } } diff --git a/sys/i386/i386/autoconf.c b/sys/i386/i386/autoconf.c index 60b372525e32..85808d5b3ce9 100644 --- a/sys/i386/i386/autoconf.c +++ b/sys/i386/i386/autoconf.c @@ -290,31 +290,32 @@ hwaddr_to_sockaddr(char *ev, struct sockaddr_dl *sa) static int decode_nfshandle(char *ev, u_char *fh) { - u_char *cp; + u_char *cp, *ep; int len, val; - if ((cp = getenv(ev)) == NULL) + ep = cp = getenv(ev); + if (cp == NULL) return(0); if ((strlen(cp) < 2) || (*cp != 'X')) { - freeenv(cp); + freeenv(ep); return (0); } len = 0; cp++; for (;;) { if (*cp == 'X') { - freeenv(cp); + freeenv(ep); return(len); } if ((sscanf(cp, "%2x", &val) != 1) || (val > 0xff)) { - freeenv(cp); + freeenv(ep); return(0); } *(fh++) = val; len++; cp += 2; if (len > NFSX_V2FH) { - freeenv(cp); + freeenv(ep); return(0); } }