summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/vfprintf.c
diff options
context:
space:
mode:
authormartynas <martynas@openbsd.org>2009-10-16 12:15:03 +0000
committermartynas <martynas@openbsd.org>2009-10-16 12:15:03 +0000
commit384cfdc17f187fdfda3c3de624a12d09397918b3 (patch)
tree829022ef0c09ec5d77cf4e4b653040c3a44dd31e /lib/libc/stdio/vfprintf.c
parentsort flags in synopsis, usage, and description. (diff)
downloadwireguard-openbsd-384cfdc17f187fdfda3c3de624a12d09397918b3.tar.xz
wireguard-openbsd-384cfdc17f187fdfda3c3de624a12d09397918b3.zip
teach gdtoa & its subroutines that malloc can fail; in which case
ecvt, fcvt, gcvt, *printf, strtof, strtod, strtold act per ieee 1003.1. after these massive changes, remove unused files which would not work now. reported by Maksymilian Arciemowicz; ok theo
Diffstat (limited to 'lib/libc/stdio/vfprintf.c')
-rw-r--r--lib/libc/stdio/vfprintf.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 466d5384a5f..7d7958b69df 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfprintf.c,v 1.53 2008/10/21 17:51:17 martynas Exp $ */
+/* $OpenBSD: vfprintf.c,v 1.54 2009/10/16 12:15:03 martynas Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -576,11 +576,19 @@ reswitch: switch (ch) {
dtoaresult = cp =
__hldtoa(fparg.ldbl, xdigs, prec,
&expt, &signflag, &dtoaend);
+ if (dtoaresult == NULL) {
+ errno = ENOMEM;
+ goto error;
+ }
} else {
fparg.dbl = GETARG(double);
dtoaresult = cp =
__hdtoa(fparg.dbl, xdigs, prec,
&expt, &signflag, &dtoaend);
+ if (dtoaresult == NULL) {
+ errno = ENOMEM;
+ goto error;
+ }
}
if (prec < 0)
prec = dtoaend - cp;
@@ -614,11 +622,19 @@ fp_begin:
dtoaresult = cp =
__ldtoa(&fparg.ldbl, expchar ? 2 : 3, prec,
&expt, &signflag, &dtoaend);
+ if (dtoaresult == NULL) {
+ errno = ENOMEM;
+ goto error;
+ }
} else {
fparg.dbl = GETARG(double);
dtoaresult = cp =
__dtoa(fparg.dbl, expchar ? 2 : 3, prec,
&expt, &signflag, &dtoaend);
+ if (dtoaresult == NULL) {
+ errno = ENOMEM;
+ goto error;
+ }
if (expt == 9999)
expt = INT_MAX;
}