daandemeyer / rpms / systemd

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