[macruby-changes] [4013] MacRuby/trunk/string.c

source_changes at macosforge.org source_changes at macosforge.org
Mon May 3 16:45:40 PDT 2010


Revision: 4013
          http://trac.macosforge.org/projects/ruby/changeset/4013
Author:   lsansonetti at apple.com
Date:     2010-05-03 16:45:39 -0700 (Mon, 03 May 2010)
Log Message:
-----------
fix a crash when trying to create a byte string out of an empty NSString

Modified Paths:
--------------
    MacRuby/trunk/string.c

Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c	2010-05-03 23:31:41 UTC (rev 4012)
+++ MacRuby/trunk/string.c	2010-05-03 23:45:39 UTC (rev 4013)
@@ -5592,6 +5592,9 @@
 rb_str_bstr(VALUE str)
 {
     if (!IS_RSTR(str)) {
+	if (CFStringGetLength((CFStringRef)str) == 0) {
+	    return rb_bstr_new();
+	}
 	const char *cptr = CFStringGetCStringPtr((CFStringRef)str,
 		kCFStringEncodingUTF8);
 	if (cptr != NULL) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100503/070202a8/attachment.html>


More information about the macruby-changes mailing list