[svn:parrot] r37556 - in trunk: src/pmc t/pmc
cotto at svn.parrot.org
cotto at svn.parrot.org
Wed Mar 18 20:44:06 UTC 2009
Author: cotto
Date: Wed Mar 18 20:44:05 2009
New Revision: 37556
URL: https://trac.parrot.org/parrot/changeset/37556
Log:
[PMC] add a null check in Sub's assign VTABLE function
fuzzing++
Modified:
trunk/src/pmc/sub.pmc
trunk/t/pmc/sub.t
Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc Wed Mar 18 20:22:38 2009 (r37555)
+++ trunk/src/pmc/sub.pmc Wed Mar 18 20:44:05 2009 (r37556)
@@ -127,7 +127,7 @@
VTABLE void set_string_native(STRING *subname) {
Parrot_sub *sub;
PMC_get_sub(INTERP, SELF, sub);
- sub->name = Parrot_str_copy(INTERP, subname);
+ sub->name = Parrot_str_copy(INTERP, subname);
}
/*
@@ -435,7 +435,8 @@
memcpy(my_sub, other_sub, sizeof (struct Parrot_sub));
/* copy the name so it's a different string in memory */
- my_sub->name = Parrot_str_copy(INTERP, my_sub->name);
+ if (my_sub->name != NULL)
+ my_sub->name = Parrot_str_copy(INTERP, my_sub->name);
}
else
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
Modified: trunk/t/pmc/sub.t
==============================================================================
--- trunk/t/pmc/sub.t Wed Mar 18 20:22:38 2009 (r37555)
+++ trunk/t/pmc/sub.t Wed Mar 18 20:44:05 2009 (r37556)
@@ -9,7 +9,7 @@
use Test::More;
use Parrot::Test::Util 'create_tempfile';
-use Parrot::Test tests => 65;
+use Parrot::Test tests => 66;
use Parrot::Config;
=head1 NAME
@@ -1537,6 +1537,16 @@
abc
OUTPUT
+pir_output_is( <<'CODE', <<'OUTPUT', 'copy sub to self' );
+.sub 'main'
+ $P0 = new ['Sub']
+ assign $P0, $P0
+ say 'no segfault'
+.end
+CODE
+no segfault
+OUTPUT
+
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
More information about the parrot-commits
mailing list