summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-05-23 08:13:46 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-05-23 08:13:46 +0000
commit3718eb180f5c850abb8b7e31524c5745d7778dc7 (patch)
tree34586186857cc3bfbc29c523099bfeae1f4f156e /tests
parent6aa9f4aef657770e128125f9e98f660e9986626a (diff)
downloadmpfr-3718eb180f5c850abb8b7e31524c5745d7778dc7.tar.gz
[tests/tstckintc.c] Fixed undefined behavior (invalid pointer).
(merged changeset r9450 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@9452 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tstckintc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/tstckintc.c b/tests/tstckintc.c
index 6aa790662..ea80bdac3 100644
--- a/tests/tstckintc.c
+++ b/tests/tstckintc.c
@@ -38,12 +38,13 @@ static void *
new_st (size_t s)
{
void *p = (void *) stack;
- stack += ALIGNED (s);
- if (MPFR_UNLIKELY (stack > (char *) &Buffer[BUFFER_SIZE]))
+
+ if (MPFR_UNLIKELY (s > (char *) &Buffer[BUFFER_SIZE] - stack))
{
printf ("[INTERNAL TEST ERROR] Stack overflow.\n");
exit (1);
}
+ stack += ALIGNED (s);
return p;
}