From: Alejandro Colomar Date: Sat, 27 May 2023 01:24:49 +0000 (+0200) Subject: xgetXXbyYY: Centralize error handling X-Git-Tag: 4.14.0-rc1~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89c9427087f029cad177eb8fee6884d1b218a3ab;p=thirdparty%2Fshadow.git xgetXXbyYY: Centralize error handling Signed-off-by: Alejandro Colomar --- diff --git a/libmisc/xgetXXbyYY.c b/libmisc/xgetXXbyYY.c index 78034bc0e..36b9a150d 100644 --- a/libmisc/xgetXXbyYY.c +++ b/libmisc/xgetXXbyYY.c @@ -54,9 +54,7 @@ result = MALLOC(LOOKUP_TYPE); if (NULL == result) { - fprintf (log_get_logfd(), _("%s: out of memory\n"), - "x" STRINGIZE(FUNCTION_NAME)); - exit (13); + goto oom; } while (true) { @@ -70,10 +68,7 @@ * the shadow *_free functions. */ LOOKUP_TYPE *ret_result = DUP_FUNCTION(result); if (NULL == ret_result) { - fprintf (log_get_logfd(), - _("%s: out of memory\n"), - "x" STRINGIZE(FUNCTION_NAME)); - exit (13); + goto oom; } free(buffer); free(result); @@ -110,13 +105,16 @@ if (result) { result = DUP_FUNCTION(result); if (NULL == result) { - fprintf (log_get_logfd(), _("%s: out of memory\n"), - "x" STRINGIZE(FUNCTION_NAME)); - exit (13); + goto oom; } } return result; #endif + +oom: + fprintf (log_get_logfd(), _("%s: out of memory\n"), + "x" STRINGIZE(FUNCTION_NAME)); + exit (13); }