From 89c9427087f029cad177eb8fee6884d1b218a3ab Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sat, 27 May 2023 03:24:49 +0200 Subject: [PATCH] xgetXXbyYY: Centralize error handling Signed-off-by: Alejandro Colomar --- libmisc/xgetXXbyYY.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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); } -- 2.47.2