[svn:parrot] r37622 - in trunk: src/pmc t/pmc
cotto at svn.parrot.org
cotto at svn.parrot.org
Sat Mar 21 18:56:21 UTC 2009
Author: cotto
Date: Sat Mar 21 18:56:20 2009
New Revision: 37622
URL: https://trac.parrot.org/parrot/changeset/37622
Log:
[PMC] make StringHandle's clone a little more robust
Modified:
trunk/src/pmc/stringhandle.pmc
trunk/t/pmc/stringhandle.t
Modified: trunk/src/pmc/stringhandle.pmc
==============================================================================
--- trunk/src/pmc/stringhandle.pmc Sat Mar 21 18:49:29 2009 (r37621)
+++ trunk/src/pmc/stringhandle.pmc Sat Mar 21 18:56:20 2009 (r37622)
@@ -71,10 +71,13 @@
PMC * const copy = pmc_new(INTERP, enum_class_StringHandle);
Parrot_StringHandle_attributes * const data_struct = PARROT_STRINGHANDLE(copy);
- data_struct->flags = old_struct->flags;
- data_struct->stringhandle = Parrot_str_copy(INTERP, old_struct->stringhandle);
- data_struct->mode = Parrot_str_copy(INTERP, old_struct->mode);
- data_struct->encoding = Parrot_str_copy(INTERP, old_struct->encoding);
+ if (old_struct->stringhandle != NULL)
+ data_struct->stringhandle = Parrot_str_copy(INTERP, old_struct->stringhandle);
+ if (old_struct->mode != NULL)
+ data_struct->mode = Parrot_str_copy(INTERP, old_struct->mode);
+ if (old_struct->encoding != NULL)
+ data_struct->encoding = Parrot_str_copy(INTERP, old_struct->encoding);
+ data_struct->flags = old_struct->flags;
return copy;
}
Modified: trunk/t/pmc/stringhandle.t
==============================================================================
--- trunk/t/pmc/stringhandle.t Sat Mar 21 18:49:29 2009 (r37621)
+++ trunk/t/pmc/stringhandle.t Sat Mar 21 18:56:20 2009 (r37622)
@@ -7,7 +7,7 @@
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 18;
+use Parrot::Test tests => 19;
=head1 NAME
@@ -583,6 +583,16 @@
utf8
OUTPUT
+pir_output_is( <<'CODE', <<'OUTPUT', "clone an uninitialized stringhandle" );
+.sub 'main'
+ $P0 = new ['StringHandle']
+ $P1 = clone $P0
+ say "ok"
+.end
+CODE
+ok
+OUTPUT
+
# RT #46843
# L<PDD22/I\/O PMC API/=item get_fd>
# NOTES: this is going to be platform dependent
More information about the parrot-commits
mailing list