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

Peter Krempa pkrempa at redhat.com
Mon Sep 23 16:51:12 UTC 2013


On 09/23/13 15:23, Daniel P. Berrange wrote:
> 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*.  */

Isn't this comment now obsolete?

> -    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");
>  
> 

ACK.

Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130923/819f0f4b/attachment-0001.sig>


More information about the libvir-list mailing list