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

Daniel P. Berrange berrange at redhat.com
Mon Sep 23 13:23:19 UTC 2013


From: "Daniel P. Berrange" <berrange at redhat.com>

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 at redhat.com>
---
 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




More information about the libvir-list mailing list