summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/asprintf.c8
-rw-r--r--lib/libc/stdio/vasprintf.c8
-rw-r--r--lib/libc/stdio/vfprintf.c11
-rw-r--r--lib/libc/stdio/vfwprintf.c20
4 files changed, 15 insertions, 32 deletions
diff --git a/lib/libc/stdio/asprintf.c b/lib/libc/stdio/asprintf.c
index bd12726fbf0..48236775908 100644
--- a/lib/libc/stdio/asprintf.c
+++ b/lib/libc/stdio/asprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asprintf.c,v 1.21 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: asprintf.c,v 1.22 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -52,10 +52,8 @@ asprintf(char **str, const char *fmt, ...)
return (ret);
err:
- if (f._bf._base) {
- free(f._bf._base);
- f._bf._base = NULL;
- }
+ free(f._bf._base);
+ f._bf._base = NULL;
*str = NULL;
errno = ENOMEM;
return (-1);
diff --git a/lib/libc/stdio/vasprintf.c b/lib/libc/stdio/vasprintf.c
index 11d90a4b187..98cdb45549f 100644
--- a/lib/libc/stdio/vasprintf.c
+++ b/lib/libc/stdio/vasprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vasprintf.c,v 1.18 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: vasprintf.c,v 1.19 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -48,10 +48,8 @@ vasprintf(char **str, const char *fmt, __va_list ap)
return (ret);
err:
- if (f._bf._base) {
- free(f._bf._base);
- f._bf._base = NULL;
- }
+ free(f._bf._base);
+ f._bf._base = NULL;
*str = NULL;
errno = ENOMEM;
return (-1);
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 1e55ad7f494..aa971796342 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfprintf.c,v 1.69 2015/09/29 03:19:24 guenther Exp $ */
+/* $OpenBSD: vfprintf.c,v 1.70 2015/12/28 22:08:18 mmcc Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -846,10 +846,8 @@ fp_common:
if (flags & LONGINT) {
wchar_t *wcp;
- if (convbuf != NULL) {
- free(convbuf);
- convbuf = NULL;
- }
+ free(convbuf);
+ convbuf = NULL;
if ((wcp = GETARG(wchar_t *)) == NULL) {
cp = "(null)";
} else {
@@ -1075,8 +1073,7 @@ overflow:
finish:
#ifdef PRINTF_WIDE_CHAR
- if (convbuf)
- free(convbuf);
+ free(convbuf);
#endif
#ifdef FLOATING_POINT
if (dtoaresult)
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c
index be83aabe7ef..520c8bc7d22 100644
--- a/lib/libc/stdio/vfwprintf.c
+++ b/lib/libc/stdio/vfwprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfwprintf.c,v 1.14 2015/09/29 03:19:24 guenther Exp $ */
+/* $OpenBSD: vfwprintf.c,v 1.15 2015/12/28 22:08:18 mmcc Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -667,10 +667,7 @@ reswitch: switch (ch) {
prec = dtoaend - dtoaresult;
if (expt == INT_MAX)
ox[1] = '\0';
- if (convbuf) {
- free(convbuf);
- convbuf = NULL;
- }
+ free(convbuf);
cp = convbuf = __mbsconv(dtoaresult, -1);
if (cp == NULL)
goto error;
@@ -719,10 +716,7 @@ fp_begin:
if (expt == 9999)
expt = INT_MAX;
}
- if (convbuf) {
- free(convbuf);
- convbuf = NULL;
- }
+ free(convbuf);
cp = convbuf = __mbsconv(dtoaresult, -1);
if (cp == NULL)
goto error;
@@ -828,10 +822,7 @@ fp_common:
char *mbsarg;
if ((mbsarg = GETARG(char *)) == NULL)
mbsarg = "(null)";
- if (convbuf) {
- free(convbuf);
- convbuf = NULL;
- }
+ free(convbuf);
convbuf = __mbsconv(mbsarg, prec);
if (convbuf == NULL) {
fp->_flags |= __SERR;
@@ -1047,8 +1038,7 @@ overflow:
ret = -1;
finish:
- if (convbuf)
- free(convbuf);
+ free(convbuf);
#ifdef FLOATING_POINT
if (dtoaresult)
__freedtoa(dtoaresult);