File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -52,22 +52,17 @@ const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result)
5252
5353 const char * cstr = CFStringGetCStringPtr (cfStr , kCFStringEncodingUTF8 );
5454 if (cstr )
55- {
5655 ffStrbufSetS (result , cstr );
57- return NULL ;
58- }
5956 else
6057 {
61- uint32_t length = CFStringGetLength (cfStr );
62- uint32_t maxLength = (uint32_t ) CFStringGetMaximumSizeForEncoding (length , kCFStringEncodingUTF8 );
63- ffStrbufEnsureFixedLengthFree (result , maxLength );
58+ uint32_t length = (uint32_t ) CFStringGetLength (cfStr );
59+ ffStrbufEnsureFixedLengthFree (result , (uint32_t ) CFStringGetMaximumSizeForEncoding (length , kCFStringEncodingUTF8 ));
6460 if (!CFStringGetCString (cfStr , result -> chars , result -> allocated , kCFStringEncodingUTF8 ))
6561 return "CFStringGetCString() failed" ;
62+ // CFStringGetCString ensures the buffer is NUL terminated
63+ // https://developer.apple.com/documentation/corefoundation/1542721-cfstringgetcstring
64+ result -> length = (uint32_t ) strnlen (result -> chars , (uint32_t )result -> allocated );
6665 }
67-
68- // CFStringGetCString ensures the buffer is NUL terminated
69- // https://developer.apple.com/documentation/corefoundation/1542721-cfstringgetcstring
70- result -> length = (uint32_t ) strnlen (result -> chars , (uint32_t )result -> allocated );
7166 }
7267 else if (CFGetTypeID (cf ) == CFDataGetTypeID ())
7368 {
You can’t perform that action at this time.
0 commit comments