Revision
596
Author
wsiegrist@apple.com
Date
2009-10-12 15:40:21 -0700 (Mon, 12 Oct 2009)

Log Message

CFStringGetBytes returns number of characters, so we need to retrive number of bytes as well for determining where to put the null at the end of result buffer.

Modified Paths

Diff

Modified: trunk/darwinxref/cfutils.c (595 => 596)


--- trunk/darwinxref/cfutils.c	2009-10-09 22:52:07 UTC (rev 595)
+++ trunk/darwinxref/cfutils.c	2009-10-12 22:40:21 UTC (rev 596)
@@ -54,8 +54,9 @@
                 CFIndex size = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
                 result = malloc(size+1);
                 if (result != NULL) {
-                        length = CFStringGetBytes(str, CFRangeMake(0, length), kCFStringEncodingUTF8, '?', 0, (UInt8*)result, size, NULL);
-                        result[length] = 0;
+			CFIndex numbytes;
+                        length = CFStringGetBytes(str, CFRangeMake(0, length), kCFStringEncodingUTF8, '?', 0, (UInt8*)result, size, &numbytes);
+                        result[numbytes] = 0;
                 }
         }
         return result;