]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
xgetXXbyYY: Centralize error handling
authorAlejandro Colomar <alx@kernel.org>
Sat, 27 May 2023 01:24:49 +0000 (03:24 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 30 May 2023 18:56:55 +0000 (13:56 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
libmisc/xgetXXbyYY.c

index 78034bc0ed2f99ab11769cd76b98639a8575808d..36b9a150d3a5a97c63270a9cc97f9f7bdfbf737b 100644 (file)
@@ -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) {
                         * 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);
        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);
 }