anitazha / rpms / systemd

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