Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gdtoa PR/56148: Andreas Gustafsson: lib/libc/stdio/...
details: https://anonhg.NetBSD.org/src/rev/379aa251d266
branches: trunk
changeset: 379048:379aa251d266
user: christos <christos%NetBSD.org@localhost>
date: Thu May 06 16:15:33 2021 +0000
description:
PR/56148: Andreas Gustafsson: lib/libc/stdio/t_printf:snprintf_float test
randomly fails.
Add checks to all places where lshift is called because it can return NULL
diffstat:
lib/libc/gdtoa/dtoa.c | 4 +++-
lib/libc/gdtoa/gdtoa.c | 12 +++++++++---
lib/libc/gdtoa/strtoIg.c | 4 +++-
lib/libc/gdtoa/strtod.c | 6 +++++-
lib/libc/gdtoa/strtodg.c | 19 +++++++++++++++----
5 files changed, 35 insertions(+), 10 deletions(-)
diffs (148 lines):
diff -r d36efc8115af -r 379aa251d266 lib/libc/gdtoa/dtoa.c
--- a/lib/libc/gdtoa/dtoa.c Thu May 06 13:23:36 2021 +0000
+++ b/lib/libc/gdtoa/dtoa.c Thu May 06 16:15:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dtoa.c,v 1.10 2012/05/16 17:48:59 alnsn Exp $ */
+/* $NetBSD: dtoa.c,v 1.11 2021/05/06 16:15:33 christos Exp $ */
/****************************************************************
@@ -787,6 +787,8 @@ dtoa
}
#endif
b = lshift(b, 1);
+ if (b == NULL)
+ return NULL;
j = cmp(b, S);
#ifdef ROUND_BIASED
if (j >= 0)
diff -r d36efc8115af -r 379aa251d266 lib/libc/gdtoa/gdtoa.c
--- a/lib/libc/gdtoa/gdtoa.c Thu May 06 13:23:36 2021 +0000
+++ b/lib/libc/gdtoa/gdtoa.c Thu May 06 16:15:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gdtoa.c,v 1.7 2019/08/01 02:27:43 riastradh Exp $ */
+/* $NetBSD: gdtoa.c,v 1.8 2021/05/06 16:15:33 christos Exp $ */
/****************************************************************
@@ -601,10 +601,16 @@ gdtoa
*/
i = ((s5 ? hi0bits(S->x[S->wds-1]) : ULbits - 1) - s2 - 4) & kmask;
m2 += i;
- if ((b2 += i) > 0)
+ if ((b2 += i) > 0) {
b = lshift(b, b2);
- if ((s2 += i) > 0)
+ if (b == NULL)
+ return NULL;
+ }
+ if ((s2 += i) > 0) {
S = lshift(S, s2);
+ if (S == NULL)
+ return NULL;
+ }
if (k_check) {
if (cmp(b,S) < 0) {
k--;
diff -r d36efc8115af -r 379aa251d266 lib/libc/gdtoa/strtoIg.c
--- a/lib/libc/gdtoa/strtoIg.c Thu May 06 13:23:36 2021 +0000
+++ b/lib/libc/gdtoa/strtoIg.c Thu May 06 16:15:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtoIg.c,v 1.4 2019/08/01 02:27:43 riastradh Exp $ */
+/* $NetBSD: strtoIg.c,v 1.5 2021/05/06 16:15:33 christos Exp $ */
/****************************************************************
@@ -119,6 +119,8 @@ strtoIg(CONST char *s00, char **se, CONS
}
else {
b1 = lshift(b1, 1);
+ if (b1 == NULL)
+ return STRTOG_NoMemory;
b1->x[0] |= 1;
--e1;
}
diff -r d36efc8115af -r 379aa251d266 lib/libc/gdtoa/strtod.c
--- a/lib/libc/gdtoa/strtod.c Thu May 06 13:23:36 2021 +0000
+++ b/lib/libc/gdtoa/strtod.c Thu May 06 16:15:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.17 2020/09/18 14:19:34 christos Exp $ */
+/* $NetBSD: strtod.c,v 1.18 2021/05/06 16:15:33 christos Exp $ */
/****************************************************************
@@ -712,6 +712,8 @@ static double
#endif
{
delta = lshift(delta,Log2P);
+ if (delta == NULL)
+ goto ovfl;
if (cmp(delta, bs) <= 0)
dval(&adj) = -0.5;
}
@@ -804,6 +806,8 @@ static double
break;
}
delta = lshift(delta,Log2P);
+ if (delta == NULL)
+ goto ovfl;
if (cmp(delta, bs) > 0)
goto drop_down;
break;
diff -r d36efc8115af -r 379aa251d266 lib/libc/gdtoa/strtodg.c
--- a/lib/libc/gdtoa/strtodg.c Thu May 06 13:23:36 2021 +0000
+++ b/lib/libc/gdtoa/strtodg.c Thu May 06 16:15:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strtodg.c,v 1.12 2013/04/19 10:41:53 joerg Exp $ */
+/* $NetBSD: strtodg.c,v 1.13 2021/05/06 16:15:33 christos Exp $ */
/****************************************************************
@@ -248,8 +248,11 @@ rvOK
}
}
}
- else if (bdif < 0)
+ else if (bdif < 0) {
b = lshift(b, -bdif);
+ if (b == NULL)
+ return STRTOG_NoMemory;
+ }
if (e < fpi->emin) {
k = fpi->emin - e;
e = fpi->emin;
@@ -679,6 +682,8 @@ strtodg(CONST char *s00, char **se, CONS
j = rve - emin;
if (j > 0) {
rvb = lshift(rvb, j);
+ if (rvb == NULL)
+ return STRTOG_NoMemory;
rvbits += j;
}
else if (j < 0) {
@@ -950,8 +955,11 @@ strtodg(CONST char *s00, char **se, CONS
return STRTOG_NoMemory;
if (abe < 0)
rshift(ab, -abe);
- else if (abe > 0)
+ else if (abe > 0) {
ab = lshift(ab, abe);
+ if (ab == NULL)
+ return STRTOG_NoMemory;
+ }
rvb0 = rvb;
if (asub) {
/* rv -= adj; */
@@ -1027,8 +1035,11 @@ strtodg(CONST char *s00, char **se, CONS
Bfree(delta);
}
if (!denorm && (j = nbits - rvbits)) {
- if (j > 0)
+ if (j > 0) {
rvb = lshift(rvb, j);
+ if (rvb == NULL)
+ return STRTOG_NoMemory;
+ }
else
rshift(rvb, -j);
rve -= j;
Home |
Main Index |
Thread Index |
Old Index