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

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



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

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

Attachment: signature.asc
Description: OpenPGP digital signature


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