From: Daniel P. Berrange Date: Mon, 23 Sep 2013 13:20:37 +0000 (+0100) Subject: Don't ignore allocation failure in virCommandAddEnvPassCommon X-Git-Tag: v1.1.3-rc1~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6912cf4faa9c6f2c28d40bbc058c004101fddf25;p=thirdparty%2Flibvirt.git Don't ignore allocation failure in virCommandAddEnvPassCommon 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 --- diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 95331a6235..7413269cb6 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -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");