]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Don't ignore allocation failure in virCommandAddEnvPassCommon
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 23 Sep 2013 13:20:37 +0000 (14:20 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 24 Sep 2013 09:52:58 +0000 (10:52 +0100)
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

index 95331a6235b826ab8fd690a75da94683c2304c3b..7413269cb69171e65ea29894864655536b89758a 100644 (file)
@@ -1279,9 +1279,10 @@ virCommandAddEnvPassCommon(virCommandPtr cmd)
     if (!cmd || cmd->has_error)
         return;
 
-    /* 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");