Skip to content

Commit

Permalink
Use goto for clearer handling of errors
Browse files Browse the repository at this point in the history
Handle memory by jumping to the end where the profile is released
  • Loading branch information
AZero13 committed Sep 14, 2024
1 parent 7e1a313 commit ab74ed8
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions scheduler/colorman.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ apple_register_profiles(
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to allocate memory for color profile.");
CFRelease(profiles);
ppdClose(ppd);
return;
goto end;
}

apple_init_profile(ppd, languages, profile, profile_id, attr->spec,
Expand Down Expand Up @@ -624,9 +622,7 @@ apple_register_profiles(
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to allocate memory for color profile.");
CFRelease(profiles);
ppdClose(ppd);
return;
goto end;
}

apple_init_profile(ppd, NULL, profile, profile_id, cm_choice->choice,
Expand Down Expand Up @@ -668,9 +664,7 @@ apple_register_profiles(
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to allocate memory for color profile.");
CFRelease(profiles);
ppdClose(ppd);
return;
goto end;
}

profile_id = _ppdHashName("Gray..");
Expand Down Expand Up @@ -698,9 +692,7 @@ apple_register_profiles(
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to allocate memory for color profile.");
CFRelease(profiles);
ppdClose(ppd);
return;
goto end;
}

switch (ppd->colorspace)
Expand Down Expand Up @@ -844,7 +836,7 @@ apple_register_profiles(
/*
* Free any memory we used...
*/

end:
CFRelease(profiles);

ppdClose(ppd);
Expand Down

0 comments on commit ab74ed8

Please sign in to comment.