diff options
author | tnn <tnn@pkgsrc.org> | 2007-07-20 00:10:06 +0000 |
---|---|---|
committer | tnn <tnn@pkgsrc.org> | 2007-07-20 00:10:06 +0000 |
commit | 4d407c5bcb278ff22961cc530c68ed5a10127aad (patch) | |
tree | 0e56c3a657f65d7fee3f9305b8397e9315e1081c /pkgtools | |
parent | 30d0b369b9ba3dcea937ba93af45f986a6d69629 (diff) | |
download | pkgsrc-4d407c5bcb278ff22961cc530c68ed5a10127aad.tar.gz |
Fix logic error in buffer handling (Hi Joerg!)
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/libnbcompat/files/asprintf.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pkgtools/libnbcompat/files/asprintf.c b/pkgtools/libnbcompat/files/asprintf.c index 7a4e95afde7..3071565fe29 100644 --- a/pkgtools/libnbcompat/files/asprintf.c +++ b/pkgtools/libnbcompat/files/asprintf.c @@ -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>. @@ -81,18 +81,18 @@ vasprintf(char **ret, const char *fmt, va_list ap) } 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; } |