From: Rose Date: Sat, 14 Sep 2024 18:47:43 +0000 (-0400) Subject: Use goto for clearer handling of errors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1049%2Fhead;p=thirdparty%2Fcups.git Use goto for clearer handling of errors Handle memory by jumping to the end where the profile is released --- diff --git a/scheduler/colorman.c b/scheduler/colorman.c index 27cd2982f1..5784c1c75b 100644 --- a/scheduler/colorman.c +++ b/scheduler/colorman.c @@ -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, @@ -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, @@ -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.."); @@ -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) @@ -844,7 +836,7 @@ apple_register_profiles( /* * Free any memory we used... */ - +end: CFRelease(profiles); ppdClose(ppd);