diff mbox series

[4/4] libsepol: expand: check for memory allocation failure

Message ID 20230714184414.40724-4-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit 1c19dc4f6408
Delegated to: Petr Lautrbach
Headers show
Series [1/4] libsepol: validate: use fixed sized integers | expand

Commit Message

Christian Göttsche July 14, 2023, 6:44 p.m. UTC
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/expand.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c
index 2ff06cd7..5c20b806 100644
--- a/libsepol/src/expand.c
+++ b/libsepol/src/expand.c
@@ -2954,6 +2954,10 @@  int expand_module(sepol_handle_t * handle,
 	state.out->policyvers = POLICYDB_VERSION_MAX;
 	if (state.base->name) {
 		state.out->name = strdup(state.base->name);
+		if (!state.out->name) {
+			ERR(handle, "Out of memory!");
+			goto cleanup;
+		}
 	}
 
 	/* Copy mls state from base to out */