[macruby-changes] [4018] MacRuby/trunk/ext/json/rubyext.c

source_changes at macosforge.org source_changes at macosforge.org
Tue May 4 14:07:54 PDT 2010


Revision: 4018
          http://trac.macosforge.org/projects/ruby/changeset/4018
Author:   lsansonetti at apple.com
Date:     2010-05-04 14:07:52 -0700 (Tue, 04 May 2010)
Log Message:
-----------
fix a crash when calling #to_json on a symbol (patch by Brian Collins)

Modified Paths:
--------------
    MacRuby/trunk/ext/json/rubyext.c

Modified: MacRuby/trunk/ext/json/rubyext.c
===================================================================
--- MacRuby/trunk/ext/json/rubyext.c	2010-05-04 20:42:19 UTC (rev 4017)
+++ MacRuby/trunk/ext/json/rubyext.c	2010-05-04 21:07:52 UTC (rev 4018)
@@ -433,6 +433,10 @@
             cptr = RSTRING_PTR(obj);
             status = yajl_gen_string(gen->generator, (const unsigned char*)cptr, (unsigned int)strlen(cptr), 1);
             break;
+        case T_SYMBOL:
+            cptr = rb_sym2name(obj);
+            status = yajl_gen_string(gen->generator, (const unsigned char*)cptr, (unsigned int)strlen(cptr), quote_strings);
+            break;
         default:
             if (rb_respond_to(obj, id_to_json)) {
                 str = rb_vm_call_with_cache(to_json_cache, obj, sel_to_json, 0, 0);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100504/0b52cf9e/attachment.html>


More information about the macruby-changes mailing list