Hi Vincent,

On Thu, Nov 17, 2016 at 02:23:13PM +0100, Vincent Bernat wrote:
> From: Vincent Bernat <[email protected]>
> 
> In case `pool_alloc2()` returns NULL, propagate the condition to the
> caller. This could happen when limiting the amount of memory available
> for HAProxy with `-m`.

Good catch, but look the original if intented to catch this but was
wrong, thus I think it's better to remove it now :

> ---
>  src/stick_table.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/stick_table.c b/src/stick_table.c
> index 7a2fcc21af8b..2d5c042174fb 100644
> --- a/src/stick_table.c
> +++ b/src/stick_table.c
> @@ -170,7 +170,10 @@ struct stksess *stksess_new(struct stktable *t, struct 
> stktable_key *key)
>                       return NULL;
>       }
>  
> -     ts = pool_alloc2(t->pool) + t->data_size;
> +     ts = pool_alloc2(t->pool);
> +     if (unlikely(ts == NULL))
> +             return NULL;
> +     ts += t->data_size;
>       if (ts) {
        ^^^^^^^^^
will always be true.

>               t->current++;
>               stksess_init(t, ts);

Or another way to fix it is to simply move the addition inside the if.

I can modify your patch if you don't have the time, just let me know.

Thanks,
Willy

Reply via email to