[svn:parrot] r37560 - in trunk: src/pmc t/pmc
cotto at svn.parrot.org
cotto at svn.parrot.org
Wed Mar 18 21:10:00 UTC 2009
Author: cotto
Date: Wed Mar 18 21:10:00 2009
New Revision: 37560
URL: https://trac.parrot.org/parrot/changeset/37560
Log:
[PMC] add null check to Sub's get_string
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 21:07:39 2009 (r37559)
+++ trunk/src/pmc/sub.pmc Wed Mar 18 21:10:00 2009 (r37560)
@@ -121,7 +121,10 @@
VTABLE STRING *get_string() {
Parrot_sub *sub;
PMC_get_sub(INTERP, SELF, sub);
- return Parrot_str_copy(INTERP, sub->name);
+ if (sub->name != NULL) {
+ return Parrot_str_copy(INTERP, sub->name);
+ }
+ return NULL;
}
VTABLE void set_string_native(STRING *subname) {
Modified: trunk/t/pmc/sub.t
==============================================================================
--- trunk/t/pmc/sub.t Wed Mar 18 21:07:39 2009 (r37559)
+++ trunk/t/pmc/sub.t Wed Mar 18 21:10:00 2009 (r37560)
@@ -9,7 +9,7 @@
use Test::More;
use Parrot::Test::Util 'create_tempfile';
-use Parrot::Test tests => 66;
+use Parrot::Test tests => 67;
use Parrot::Config;
=head1 NAME
@@ -1547,6 +1547,16 @@
no segfault
OUTPUT
+pir_output_is( <<'CODE', <<'OUTPUT', 'get_string null check' );
+.sub 'main'
+ $P0 = new ['Sub']
+ $S0 = $P0
+ say 'ok'
+.end
+CODE
+ok
+OUTPUT
+
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
More information about the parrot-commits
mailing list