[PATCH 10/10] Don't ignore allocation failure in virCommandAddEnvPassCommon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The virCommandAddEnvPassCommon method ignored the failure to
pre-allocate the env variable array with VIR_RESIZE_N. While
this is harmless, it confuses the test harness which is trying
to validate OOM handling of every individual allocation call.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/util/vircommand.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 95331a6..933028e 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -1281,7 +1281,10 @@ virCommandAddEnvPassCommon(virCommandPtr cmd)
 
     /* Attempt to Pre-allocate; allocation failure will be detected
      * later during virCommandAdd*.  */
-    ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 9));
+    if (VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 9) < 0) {
+        cmd->has_error = ENOMEM;
+        return;
+    }
 
     virCommandAddEnvPair(cmd, "LC_ALL", "C");
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]