Skip to content

Commit dde51d3

Browse files
committed
Swift: do not rely on CFStringGetLength
1 parent 0521855 commit dde51d3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

swift/xcode-autobuilder/XcodeProjectParser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ struct CFKeyValues {
3232
static std::string stringValue(CFDictionaryRef dict, CFStringRef key) {
3333
auto cfValue = (CFStringRef)CFDictionaryGetValue(dict, key);
3434
if (cfValue) {
35-
auto length = CFStringGetLength(cfValue);
36-
std::string s(length, '\0');
37-
if (CFStringGetCString(cfValue, s.data(), length + 1, kCFStringEncodingUTF8)) {
38-
return s;
35+
const int bufferSize = 256;
36+
char buf[bufferSize];
37+
if (CFStringGetCString(cfValue, buf, bufferSize, kCFStringEncodingUTF8)) {
38+
return {buf};
3939
}
4040
}
4141
return {};

0 commit comments

Comments
 (0)