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

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



From: "Daniel P. Berrange" <berrange 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 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


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