diff --git a/src/lib/libc/stdlib/ecvt.c b/src/lib/libc/stdlib/ecvt.c index 719370a8..03ff9189 100644 --- a/src/lib/libc/stdlib/ecvt.c +++ b/src/lib/libc/stdlib/ecvt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecvt.c,v 1.6 2006/10/29 18:45:56 deraadt Exp $ */ +/* $OpenBSD: ecvt.c,v 1.7 2009/10/16 12:15:03 martynas Exp $ */ /* * Copyright (c) 2002, 2006 Todd C. Miller @@ -62,6 +62,8 @@ __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad) *rve = '\0'; } else { p = __dtoa(value, fmode + 2, ndigit, decpt, sign, &rve); + if (p == NULL) + return (NULL); if (*decpt == 9999) { /* Infinity or Nan, convert to inf or nan like printf */ *decpt = 0; diff --git a/src/lib/libc/stdlib/gcvt.c b/src/lib/libc/stdlib/gcvt.c index c24157e4..e5488d91 100644 --- a/src/lib/libc/stdlib/gcvt.c +++ b/src/lib/libc/stdlib/gcvt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gcvt.c,v 1.10 2006/10/29 18:45:56 deraadt Exp $ */ +/* $OpenBSD: gcvt.c,v 1.11 2009/10/16 12:15:03 martynas Exp $ */ /* * Copyright (c) 2002, 2003, 2006 Todd C. Miller @@ -42,6 +42,8 @@ gcvt(double value, int ndigit, char *buf) } digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL); + if (digits == NULL) + return (NULL); if (decpt == 9999) { /* * Infinity or NaN, convert to inf or nan with sign.