24ea25
From e34f49c1966fcaa9390a544a0136ec189a3c870e Mon Sep 17 00:00:00 2001
24ea25
From: Serge Hallyn <serge@hallyn.com>
24ea25
Date: Mon, 17 May 2021 08:48:03 -0500
24ea25
Subject: [PATCH] libsubid_init: return false if out of memory
24ea25
24ea25
The rest of the run isn't likely to get much better, is it?
24ea25
24ea25
Thanks to Alexey for pointing this out.
24ea25
24ea25
Signed-off-by: Serge Hallyn <serge@hallyn.com>
24ea25
Cc: Alexey Tikhonov <atikhono@redhat.com>
24ea25
---
24ea25
 libsubid/api.c | 6 ++++--
24ea25
 1 file changed, 4 insertions(+), 2 deletions(-)
24ea25
24ea25
diff --git a/libsubid/api.c b/libsubid/api.c
24ea25
index 8ca09859..8618e500 100644
24ea25
--- a/libsubid/api.c
24ea25
+++ b/libsubid/api.c
24ea25
@@ -46,10 +46,12 @@ bool libsubid_init(const char *progname, FILE * logfd)
24ea25
 {
24ea25
 	if (progname) {
24ea25
 		progname = strdup(progname);
24ea25
-		if (progname)
24ea25
+		if (progname) {
24ea25
 			Prog = progname;
24ea25
-		else
24ea25
+		} else {
24ea25
 			fprintf(stderr, "Out of memory");
24ea25
+			return false;
24ea25
+		}
24ea25
 	}
24ea25
 
24ea25
 	if (logfd) {
24ea25
-- 
24ea25
2.30.2
24ea25