[svn:parrot] r37563 - in trunk: src/string t/op
cotto at svn.parrot.org
cotto at svn.parrot.org
Wed Mar 18 22:07:16 UTC 2009
Author: cotto
Date: Wed Mar 18 22:07:14 2009
New Revision: 37563
URL: https://trac.parrot.org/parrot/changeset/37563
Log:
[string] make Parrot_encoding_name and a similar function check for negative values
fuzzing++
Modified:
trunk/src/string/encoding.c
trunk/t/op/string.t
Modified: trunk/src/string/encoding.c
==============================================================================
--- trunk/src/string/encoding.c Wed Mar 18 21:38:32 2009 (r37562)
+++ trunk/src/string/encoding.c Wed Mar 18 22:07:14 2009 (r37563)
@@ -229,7 +229,8 @@
Parrot_encoding_name(SHIM_INTERP, INTVAL number_of_encoding)
{
ASSERT_ARGS(Parrot_encoding_name)
- if (number_of_encoding >= all_encodings->n_encodings)
+ if (number_of_encoding >= all_encodings->n_encodings ||
+ number_of_encoding < 0)
return NULL;
return all_encodings->enc[number_of_encoding].name;
}
@@ -275,7 +276,8 @@
Parrot_encoding_c_name(SHIM_INTERP, INTVAL number_of_encoding)
{
ASSERT_ARGS(Parrot_encoding_c_name)
- if (number_of_encoding >= all_encodings->n_encodings)
+ if (number_of_encoding >= all_encodings->n_encodings ||
+ number_of_encoding < 0)
return NULL;
return all_encodings->enc[number_of_encoding].encoding->name;
}
Modified: trunk/t/op/string.t
==============================================================================
--- trunk/t/op/string.t Wed Mar 18 21:38:32 2009 (r37562)
+++ trunk/t/op/string.t Wed Mar 18 22:07:14 2009 (r37563)
@@ -7,7 +7,7 @@
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 162;
+use Parrot::Test tests => 163;
use Parrot::Config;
=head1 NAME
@@ -1300,6 +1300,18 @@
.end
CODE
+pir_output_is( <<'CODE', <<'OUTPUT', 'encodingname OOB' );
+.sub main
+ $I0 = -1
+
+ $S0 = encodingname -1
+ $S0 = encodingname $I0
+ say 'ok'
+.end
+CODE
+ok
+OUTPUT
+
pasm_output_is( <<'CODE', <<'OUTPUT', 'index, 3-arg form' );
set S0, "Parrot"
set S1, "Par"
More information about the parrot-commits
mailing list