Stop v111111111111111 from leaking under fatal warnings
authorFather Chrysostomos <sprout@cpan.org>
Wed, 5 Dec 2012 06:05:09 +0000 (22:05 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 5 Dec 2012 17:36:09 +0000 (09:36 -0800)
Actually, you need more digits than that to get a leak.

This commit arranges for the SV passed to scan_vstring to be freed
in case scan_vstring triggers an integer overflow warning when fatal
warnings are enabled.

t/op/svleak.t
toke.c

index 475baed..3c15119 100644 (file)
@@ -103,10 +103,8 @@ eleak(2, 0, "$all /(?{})+/ ", '(?{})+ with fatal warnings');
 eleak(2, 0, "$all /[\\i]/ ", 'invalid charclass escape with fatal warns');
 eleak(2, 0, "$all /[:foo:]/ ", '/[:foo:]/ with fatal warnings');
 eleak(2, 0, "$all /[a-\\d]/ ", '[a-\d] char class with fatal warnings');
-$::TODO = 'still leaks';
 eleak(2, 0, "$all v111111111111111111111111111111111111111111111111",
      'vstring num overflow with fatal warnings');
-undef $::TODO;
 
 eleak(2, 0, 'sub{<*>}');
 
diff --git a/toke.c b/toke.c
index 7b6f194..df3e9a8 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -10987,7 +10987,11 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
     case 'v':
 vstring:
                sv = newSV(5); /* preallocate storage space */
+               ENTER_with_name("scan_vstring");
+               SAVEFREESV(sv);
                s = scan_vstring(s, PL_bufend, sv);
+               SvREFCNT_inc_simple_void_NN(sv);
+               LEAVE_with_name("scan_vstring");
        break;
     }