cvsuser 04/08/16 02:11:03
Modified: src string.c
Log:
Mea culpa: if there was leading whitespace, the free accessed unaligned memory.
Revision Changes Path
1.217 +5 -4 parrot/src/string.c
Index: string.c
===================================================================
RCS file: /cvs/public/parrot/src/string.c,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -w -r1.216 -r1.217
--- string.c 15 Aug 2004 18:08:02 -0000 1.216
+++ string.c 16 Aug 2004 09:11:02 -0000 1.217
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: string.c,v 1.216 2004/08/15 18:08:02 jhi Exp $
+$Id: string.c,v 1.217 2004/08/16 09:11:02 jhi Exp $
=head1 NAME
@@ -2530,10 +2530,11 @@
* XXX would strtod() be better for detecting malformed input?
*/
char *cstr = string_to_cstring(interpreter, const_cast(s));
- while (isspace(*cstr)) cstr++;
- f = atof(cstr);
+ char *p = cstrs;
+ while (isspace(*p)) p++;
+ f = atof(p);
/* Not all atof()s return -0 from "-0" */
- if (*cstr == '-' && f == 0.0)
+ if (*p == '-' && f == 0.0)
f = -0.0;
string_cstring_free(cstr);
return f;