[Bast-commits] r4876 - Devel-Declare/1.000/trunk
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Sat Oct 4 14:18:02 BST 2008
Author: rafl
Date: 2008-10-04 14:18:02 +0100 (Sat, 04 Oct 2008)
New Revision: 4876
Modified:
Devel-Declare/1.000/trunk/Declare.xs
Log:
Check if reallocation of PL_linestr is necessary before doing it.
That way memory curruption caused by SvGROW on a PL_linestr comming from perl
-e goes away.
Modified: Devel-Declare/1.000/trunk/Declare.xs
===================================================================
--- Devel-Declare/1.000/trunk/Declare.xs 2008-10-04 02:32:03 UTC (rev 4875)
+++ Devel-Declare/1.000/trunk/Declare.xs 2008-10-04 13:18:02 UTC (rev 4876)
@@ -118,11 +118,12 @@
int new_len = strlen(new_value);
char* old_linestr = SvPVX(PL_linestr);
+ if (SvLEN(PL_linestr) < new_len) {
+ croak("forced to realloc PL_linestr for line %s, bailing out before we crash harder", SvPVX(PL_linestr));
+ }
+
SvGROW(PL_linestr, new_len);
- if (SvPVX(PL_linestr) != old_linestr)
- croak("forced to realloc PL_linestr for line %s, bailing out before we crash harder", SvPVX(PL_linestr));
-
memcpy(SvPVX(PL_linestr), new_value, new_len+1);
SvCUR_set(PL_linestr, new_len);
More information about the Bast-commits
mailing list