summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-01-18 11:30:00 -0700
committerKarl Williamson <khw@cpan.org>2019-01-18 21:48:16 -0700
commitaac39b038830b7472ba3f079b4aee72cb2076c2e (patch)
tree9925a0eb6af94e85d0340277adf3df64ddc66309 /numeric.c
parent0657084328c6c5c8225ddf2ce8238561011f6bff (diff)
downloadperl-aac39b038830b7472ba3f079b4aee72cb2076c2e.tar.gz
my_atof3() Fix uncommon bug where it wrongly fails
This bug showed up only on -Dusemymalloc without Debugging, and without various other common Configure options. It causes my_atof3() to return failure where in fact success was achieved. It apparently got triggered due to slight differences in malloc behaviors. The bug is that it changed a string pointer to new memory and forgot to change it back to the original value when that memory got freed. The test that fails is an equal/not equal of two pointers, and usually two pointers aren't the same, meaning the bug doesn't appear. The only case where my_atof3() is called is in parsing certain \p{nv=...} where "..." is not a rational number. So the scope of this bug is limited. Spotted by Ryan Voots.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/numeric.c b/numeric.c
index e5e08cb241..9804a9b341 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1465,6 +1465,7 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value, STRLEN len)
/* If we created a copy, 'endp' is in terms of that. Convert back to
* the original */
if (copy) {
+ s = (s - copy) + (char *) orig;
endp = (endp - copy) + (char *) orig;
Safefree(copy);
}