[MacRuby] #1313: #to_json will cause a stack overflow if generating a collection with objective-c objects

MacRuby ruby-noreply at macosforge.org
Tue Jun 21 17:56:24 PDT 2011


#1313: #to_json will cause a stack overflow if generating a collection with
objective-c objects
------------------------------------+---------------------------------------
 Reporter:  mrada@…                 |       Owner:  lsansonetti@…         
     Type:  defect                  |      Status:  new                   
 Priority:  critical                |   Milestone:                        
Component:  MacRuby                 |    Keywords:  reduction 0.11-blocker
------------------------------------+---------------------------------------

Comment(by watson1978@…):

 Does it have problem if NSString#to_s would return a RubyString?

 {{{
 #!diff
 diff --git a/NSString.m b/NSString.m
 index 99f47db..4333021 100644
 --- a/NSString.m
 +++ b/NSString.m
 @@ -64,7 +64,14 @@ nsstr_dup(id rcv, SEL sel)
  static id
  nsstr_to_s(id rcv, SEL sel)
  {
 -    return rcv;
 +    id rstr = (id)str_new_from_cfstring((CFStringRef)rcv);
 +    if (OBJ_TAINTED(rcv)) {
 +       OBJ_TAINT(rstr);
 +    }
 +    if (![rcv respondsToSelector:@selector(setString:)]) {
 +       OBJ_FREEZE(rstr);
 +    }
 +    return rstr;
  }

  static id
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1313#comment:4>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list