Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CFStringCreateWithCStringNoCopy when the CFString doesn't outlast the char * #1081

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/usb-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ CFStringRef cfstr_create_trim(const char *cstr)
CFStringRef cfstr;
CFMutableStringRef cfmutablestr = NULL;

if ((cfstr = CFStringCreateWithCString(kCFAllocatorDefault, cstr, kCFStringEncodingUTF8)) != NULL)
if ((cfstr = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, cstr, kCFStringEncodingUTF8, NULL)) != NULL)
{
if ((cfmutablestr = CFStringCreateMutableCopy(kCFAllocatorDefault, 1024, cfstr)) != NULL)
CFStringTrimWhitespace(cfmutablestr);
Expand Down Expand Up @@ -2071,7 +2071,7 @@ static void setup_cfLanguage(void)
return;
}

lang[0] = CFStringCreateWithCString(kCFAllocatorDefault, requestedLang, kCFStringEncodingUTF8);
lang[0] = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, requestedLang, kCFStringEncodingUTF8, NULL);
langArray = CFArrayCreate(kCFAllocatorDefault, (const void **)lang, sizeof(lang) / sizeof(lang[0]), &kCFTypeArrayCallBacks);

CFPreferencesSetValue(CFSTR("AppleLanguages"), langArray, kCFPreferencesCurrentApplication, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
Expand Down
2 changes: 1 addition & 1 deletion cups/dest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,7 @@ cupsSetDests2(http_t *http, // I - Connection to server or @code CUPS_HTTP_

if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) != NULL)
{
CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, dest->name, kCFStringEncodingUTF8);
CFStringRef name = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, dest->name, kCFStringEncodingUTF8, NULL);
// Default printer name

if (name)
Expand Down
16 changes: 8 additions & 8 deletions scheduler/colorman.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ apple_init_profile(
return;
}

cftext = CFStringCreateWithCString(kCFAllocatorDefault, text,
kCFStringEncodingUTF8);
cftext = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, text,
kCFStringEncodingUTF8, NULL);

if (cftext)
{
Expand Down Expand Up @@ -281,10 +281,10 @@ apple_init_profile(

if (attr && attr->text[0])
{
cflang = CFStringCreateWithCString(kCFAllocatorDefault, language,
kCFStringEncodingUTF8);
cftext = CFStringCreateWithCString(kCFAllocatorDefault, attr->text,
kCFStringEncodingUTF8);
cflang = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, language,
kCFStringEncodingUTF8, NULL);
cftext = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, attr->text,
kCFStringEncodingUTF8, NULL);

if (cflang && cftext)
CFDictionarySetValue(dict, cflang, cftext);
Expand Down Expand Up @@ -766,8 +766,8 @@ apple_register_profiles(
device_name = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
printer_name = CFStringCreateWithCString(kCFAllocatorDefault,
p->name, kCFStringEncodingUTF8);
printer_name = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
p->name, kCFStringEncodingUTF8, NULL);

if (device_name && printer_name)
{
Expand Down
Loading