From 4780cd1a790286213dda646f782fa7128fb092a9 Mon Sep 17 00:00:00 2001
From: Yugend <77495782+Yugend@users.noreply.github.com>
Date: Sat, 4 May 2024 00:39:36 +0300
Subject: [PATCH] avoiding of NULL pointers dereference (#366)

Reference:https://github.com/linux-audit/audit-userspace/commit/4780cd1a790286213dda646f782fa7128fb092a9
Conflict:NA

---
 src/ausearch-parse.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/ausearch-parse.c b/src/ausearch-parse.c
index 1a5b047f..be57606b 100644
--- a/src/ausearch-parse.c
+++ b/src/ausearch-parse.c
@@ -719,6 +719,10 @@ static int common_path_parser(search_items *s, char *path)
 			// append
 			snode sn;
 			sn.str = strdup(path);
+			if (sn.str == NULL) {
+				fprintf(stderr, "Out of memory. Check %s file, %d line\n", __FILE__, __LINE__);
+				return 8;
+			}
 			sn.key = NULL;
 			sn.hits = 1;
 			// Attempt to rebuild path if relative
@@ -1217,6 +1221,10 @@ skip:
 			saved = *term;
 			*term = 0;
 			s->hostname = strdup(str);
+			if (s->hostname == NULL) {
+				fprintf(stderr, "Out of memory. Check %s file, %d line\n", __FILE__, __LINE__);
+				return 33;
+			}
 			*term = saved;
 
 			// Lets see if there is something more
-- 
2.33.0

