valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0435-shared-check-strdup-NULL.patch

a19bc6
From eb591ab12405209edb498c9c57ddf76862c237c5 Mon Sep 17 00:00:00 2001
a19bc6
From: Evgeny Vereshchagin <evvers@ya.ru>
a19bc6
Date: Mon, 9 Jan 2017 22:45:41 +0000
a19bc6
Subject: [PATCH] shared: check strdup != NULL
a19bc6
a19bc6
This is a follow-up for dc7dd61de610e9330
a19bc6
a19bc6
(cherry picked from commit d054eae6c954baa857170bb60072c8a2ecea0d6b)
a19bc6
Related: #1409997
a19bc6
---
a19bc6
 src/shared/install.c | 6 +++++-
a19bc6
 1 file changed, 5 insertions(+), 1 deletion(-)
a19bc6
a19bc6
diff --git a/src/shared/install.c b/src/shared/install.c
181b3f
index 87d805c94..62bdf674c 100644
a19bc6
--- a/src/shared/install.c
a19bc6
+++ b/src/shared/install.c
a19bc6
@@ -1639,7 +1639,11 @@ int unit_file_unmask(
a19bc6
                 if (!GREEDY_REALLOC0(todo, n_allocated, n_todo + 2))
a19bc6
                         return -ENOMEM;
a19bc6
 
a19bc6
-                todo[n_todo++] = strdup(*i);
a19bc6
+                todo[n_todo] = strdup(*i);
a19bc6
+                if (!todo[n_todo])
a19bc6
+                        return -ENOMEM;
a19bc6
+
a19bc6
+                n_todo++;
a19bc6
         }
a19bc6
 
a19bc6
         strv_uniq(todo);