Author: stefanbidi
Date: Sun Jul 12 20:36:04 2015
New Revision: 38787

URL: http://svn.gna.org/viewcvs/gnustep?rev=38787&view=rev
Log:
* Source/CFPropertyList.c: Fix string size bug.
* Source/CFString.c: Fix string conversion bug.

Modified:
    libs/corebase/trunk/ChangeLog
    libs/corebase/trunk/Source/CFPropertyList.c
    libs/corebase/trunk/Source/CFString.c

Modified: libs/corebase/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/corebase/trunk/ChangeLog?rev=38787&r1=38786&r2=38787&view=diff
==============================================================================
--- libs/corebase/trunk/ChangeLog       (original)
+++ libs/corebase/trunk/ChangeLog       Sun Jul 12 20:36:04 2015
@@ -1,3 +1,7 @@
+2015-07-12 Stefan Bidigaray <[email protected]>
+       * Source/CFPropertyList.c: Fix string size bug.
+       * Source/CFString.c: Fix string conversion bug.
+
 2015-07-10 Stefan Bidigaray <[email protected]>
        * Doxyfile: Adjust documentation options.
        * Documentation/MainPage.dox: Fix typo.

Modified: libs/corebase/trunk/Source/CFPropertyList.c
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/corebase/trunk/Source/CFPropertyList.c?rev=38787&r1=38786&r2=38787&view=diff
==============================================================================
--- libs/corebase/trunk/Source/CFPropertyList.c (original)
+++ libs/corebase/trunk/Source/CFPropertyList.c Sun Jul 12 20:36:04 2015
@@ -1266,7 +1266,7 @@
   return NULL;
 }
 
-static const UInt8 *_kCFBinaryPlistHeader = (const UInt8 *) "bplist00";
+static const UInt8 _kCFBinaryPlistHeader[] = "bplist00";
 static const CFIndex _kCFBinaryPlistHeaderLength =
   sizeof (_kCFBinaryPlistHeader) - 1;
 
@@ -1275,7 +1275,7 @@
 {
 }
 
-static const UInt8 *_kCFXMLPlistHeader = (const UInt8 *)
+static const UInt8 _kCFXMLPlistHeader[] =
   "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
   "<!DOCTYPE plist PUBLIC \"-//GNUstep//DTD plist 0.9//EN\" 
\"http://www.gnustep.org/plist-0_9.dtd\";>\n"
   "<plist version=\"0.9\">\n";

Modified: libs/corebase/trunk/Source/CFString.c
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/corebase/trunk/Source/CFString.c?rev=38787&r1=38786&r2=38787&view=diff
==============================================================================
--- libs/corebase/trunk/Source/CFString.c       (original)
+++ libs/corebase/trunk/Source/CFString.c       Sun Jul 12 20:36:04 2015
@@ -908,22 +908,28 @@
 {
   UInt8 *buffer;
   CFRange range;
-  CFIndex numBytes;
+  CFIndex converted;
   CFIndex strLen;
   CFIndex len;
   CFIndex usedLen = 0;
 
   strLen = CFStringGetLength (str);
   range = CFRangeMake (0, strLen);
-  len = strLen + 1;             /* include space for a NULL byte. */
+  converted = CFStringGetBytes (str, range, encoding, lossByte, true, NULL, 0, 
&len);
+  if (converted == 0)
+    return NULL;
+  len += 1;             /* include space for a NULL byte. */
 
   buffer = CFAllocatorAllocate (alloc, len, 0);
 
-  numBytes = CFStringGetBytes (str, range, encoding, lossByte,
-                               true, buffer, len, &usedLen);
-
-  if (numBytes == 0)
-    return NULL;
+  converted = CFStringGetBytes (str, range, encoding, lossByte,
+                                true, buffer, len, &usedLen);
+
+  if (converted == 0)
+    {
+      CFAllocatorDeallocate (alloc, buffer);
+      return NULL;
+    }
 
   return CFDataCreateWithBytesNoCopy (alloc, buffer, usedLen, alloc);
 }


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to