Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/getNAME realloc mistake



details:   https://anonhg.NetBSD.org/src/rev/f8b38eb88009
branches:  trunk
changeset: 552108:f8b38eb88009
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Sep 19 05:41:33 2003 +0000

description:
realloc mistake

diffstat:

 libexec/getNAME/getNAME.c |  22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diffs (70 lines):

diff -r 1766dd9a5105 -r f8b38eb88009 libexec/getNAME/getNAME.c
--- a/libexec/getNAME/getNAME.c Fri Sep 19 05:36:59 2003 +0000
+++ b/libexec/getNAME/getNAME.c Fri Sep 19 05:41:33 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getNAME.c,v 1.21 2003/08/07 09:46:40 agc Exp $ */
+/*     $NetBSD: getNAME.c,v 1.22 2003/09/19 05:41:33 itojun Exp $      */
 
 /*-
  * Copyright (c) 1980, 1993
@@ -69,7 +69,7 @@
 #if 0
 static char sccsid[] = "@(#)getNAME.c  8.1 (Berkeley) 6/30/93";
 #else
-__RCSID("$NetBSD: getNAME.c,v 1.21 2003/08/07 09:46:40 agc Exp $");
+__RCSID("$NetBSD: getNAME.c,v 1.22 2003/09/19 05:41:33 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -191,9 +191,10 @@
 oldman(pathname, name)
        char *pathname, *name;
 {
-       char *line, *ext, *s;
+       char *line, *ext, *s, *newlinebuf;
        size_t len, i, extlen;
        size_t curlen = 0;
+       size_t newmaxlen;
 
        if (typeflag) {
                printf("%-60s\tOLD\n", pathname);
@@ -258,9 +259,11 @@
                        extlen = 0;
 
                if (maxlen + extlen < curlen + len + SLOP) {
-                       maxlen = 2 * (curlen + len) + SLOP + extlen;
-                       if ((linebuf = realloc(linebuf, maxlen)) == NULL)
+                       newmaxlen = 2 * (curlen + len) + SLOP + extlen;
+                       if ((newlinebuf = realloc(linebuf, newmaxlen)) == NULL)
                                err(1, NULL);
+                       linebuf = newlinebuf;
+                       maxlen = newmaxlen;
                }
                if (i != 0)
                        linebuf[curlen++] = ' ';
@@ -298,9 +301,10 @@
 newman(pathname, name)
        char *pathname, *name;
 {
-       char *line, *ext, *s;
+       char *line, *ext, *s, *newlinebuf;
        size_t len, i, extlen;
        size_t curlen = 0;
+       size_t newmaxlen;
 
        if (typeflag) {
                printf("%-60s\tNEW\n", pathname);
@@ -359,9 +363,11 @@
                        extlen = 0;
 
                if (maxlen + extlen < curlen + len + SLOP) {
-                       maxlen = 2 * (curlen + len) + SLOP + extlen;
-                       if ((linebuf = realloc(linebuf, maxlen)) == NULL)
+                       newmaxlen = 2 * (curlen + len) + SLOP + extlen;
+                       if ((newlinebuf = realloc(linebuf, newmaxlen)) == NULL)
                                err(1, NULL);
+                       linebuf = newlinebuf;
+                       maxlen = newmaxlen;
                }
 
                if (i != 0)



Home | Main Index | Thread Index | Old Index