diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2009-10-16 12:15:04 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2009-10-16 12:15:04 +0000 |
commit | 7d672698297cd690f731fb42ff14a0e3ddb35755 (patch) | |
tree | fe02a524f7f5098071b58f8a2d7141fb1c30cf65 /lib/libc/stdio/vfprintf.c | |
parent | 261fc86bcfe671993b508087f8707ba7f1f1ad27 (diff) |
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.c | 18 |
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; } |