ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
Blob Blame History Raw
From eb591ab12405209edb498c9c57ddf76862c237c5 Mon Sep 17 00:00:00 2001
From: Evgeny Vereshchagin <evvers@ya.ru>
Date: Mon, 9 Jan 2017 22:45:41 +0000
Subject: [PATCH] shared: check strdup != NULL

This is a follow-up for dc7dd61de610e9330

(cherry picked from commit d054eae6c954baa857170bb60072c8a2ecea0d6b)
Related: #1409997
---
 src/shared/install.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index 87d805c941..62bdf674c9 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1639,7 +1639,11 @@ int unit_file_unmask(
                 if (!GREEDY_REALLOC0(todo, n_allocated, n_todo + 2))
                         return -ENOMEM;
 
-                todo[n_todo++] = strdup(*i);
+                todo[n_todo] = strdup(*i);
+                if (!todo[n_todo])
+                        return -ENOMEM;
+
+                n_todo++;
         }
 
         strv_uniq(todo);