pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/libnbcompat/files Fix logic error in buffer h...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/065a0b752d94
branches:  trunk
changeset: 531111:065a0b752d94
user:      tnn <tnn%pkgsrc.org@localhost>
date:      Fri Jul 20 00:10:06 2007 +0000

description:
Fix logic error in buffer handling (Hi Joerg!)

diffstat:

 pkgtools/libnbcompat/files/asprintf.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (33 lines):

diff -r 8614b7b83d61 -r 065a0b752d94 pkgtools/libnbcompat/files/asprintf.c
--- a/pkgtools/libnbcompat/files/asprintf.c     Fri Jul 20 00:09:21 2007 +0000
+++ b/pkgtools/libnbcompat/files/asprintf.c     Fri Jul 20 00:10:06 2007 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: asprintf.c,v 1.1 2007/06/25 21:35:04 joerg Exp $ */
+/* $NetBSD: asprintf.c,v 1.2 2007/07/20 00:10:06 tnn Exp $ */
 
 /*-
  * Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -81,18 +81,18 @@
        }
 
        len = (size_t)retval + 1;
-       new_buf = realloc(buf, len);
-       if (new_buf == NULL) {
-               free(buf);
+       free(buf);
+       buf = malloc(len);
+       if (buf == NULL) {
                *ret = NULL;
                return -1;
        }
        retval = vsnprintf(buf, len, fmt, ap);
        if (retval != len - 1) {
-               free(new_buf);
+               free(buf);
                *ret = NULL;
                return -1;
        }
-       *ret = new_buf;
+       *ret = buf;
        return retval;
 }



Home | Main Index | Thread Index | Old Index