File tree 1 file changed +5
-10
lines changed
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)
52
52
53
53
const char * cstr = CFStringGetCStringPtr (cfStr , kCFStringEncodingUTF8 );
54
54
if (cstr )
55
- {
56
55
ffStrbufSetS (result , cstr );
57
- return NULL ;
58
- }
59
56
else
60
57
{
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 , CFStringGetMaximumSizeForEncoding (length , kCFStringEncodingUTF8 ));
64
60
if (!CFStringGetCString (cfStr , result -> chars , result -> allocated , kCFStringEncodingUTF8 ))
65
61
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 );
66
65
}
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 );
71
66
}
72
67
else if (CFGetTypeID (cf ) == CFDataGetTypeID ())
73
68
{
You can’t perform that action at this time.
0 commit comments