]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stick-table: handle out-of-memory condition gracefully
authorVincent Bernat <vincent@bernat.im>
Thu, 17 Nov 2016 14:42:40 +0000 (15:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Nov 2016 15:00:16 +0000 (16:00 +0100)
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`.

[wt: backport to 1.6 and 1.5 needed]

src/stick_table.c

index 7a2fcc21af8bb33643d985ab65877f2710c90813..7026fe65659a1c03a831d7a434aae59377570b4f 100644 (file)
@@ -170,9 +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 (ts) {
                t->current++;
+               ts += t->data_size;
                stksess_init(t, ts);
                if (key)
                        stksess_setkey(t, ts, key);