diff options
author | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-12-19 02:42:33 +0000 |
---|---|---|
committer | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-12-19 02:42:33 +0000 |
commit | af740cbea7486b878cab875de9c917db69a72e53 (patch) | |
tree | e75e97b01282d1d7d4f638540689bbf7c2c1ad8a /ext/syck | |
parent | ddc5114c139dfdb2fa091c4d33bd6a8e1caccf6f (diff) | |
download | ruby-af740cbea7486b878cab875de9c917db69a72e53.tar.gz ruby-af740cbea7486b878cab875de9c917db69a72e53.tar.xz ruby-af740cbea7486b878cab875de9c917db69a72e53.zip |
* ext/syck/rubyext.c: sorry, I reverted my "should set newly
allocated memory instead of RString's internal storage" stuff.
node allocated in rubyext.c seems to be freed by rb_syck_free_node
not syck_free_node, and it won't free data.str->ptr and type_id.
(I still think this is unsafe because RString(foo)->ptr becomes
dangling pointer when RString is modified or freed, but anyway
I misunderstood, so go back to original code for now)
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck')
-rw-r--r-- | ext/syck/rubyext.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c index c2e71b8b9..289801e49 100644 --- a/ext/syck/rubyext.c +++ b/ext/syck/rubyext.c @@ -1536,7 +1536,7 @@ syck_scalar_value_set( self, val ) Data_Get_Struct( self, SyckNode, node ); StringValue( val ); - node->data.str->ptr = syck_strndup( RSTRING(val)->ptr, RSTRING(val)->len ); + node->data.str->ptr = RSTRING(val)->ptr; node->data.str->len = RSTRING(val)->len; node->data.str->style = scalar_none; @@ -1805,13 +1805,10 @@ syck_node_type_id_set( self, type_id ) SyckNode *node; Data_Get_Struct( self, SyckNode, node ); - if ( node->type_id != NULL ) S_FREE( node->type_id ); - if ( NIL_P( type_id ) ) { node->type_id = NULL; } else { - StringValue( type_id ); - node->type_id = syck_strndup( RSTRING(type_id)->ptr, RSTRING(type_id)->len ); + node->type_id = StringValuePtr( type_id ); } rb_iv_set( self, "@type_id", type_id ); |