]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] appsession: possible memory leak in case of out of memory condition
authorCyril Bonté <cyril.bonte@free.fr>
Sat, 9 Jan 2010 23:30:14 +0000 (00:30 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 Jan 2010 22:16:37 +0000 (23:16 +0100)
I've tried to follow all the pool_alloc2/pool_free2 calls in the code
to track memory leaks. I've found one which only happens when there's
already no more memory when allocating a new appsession cookie.

(cherry picked from commit 41689c22da8bcbb877449a0ce20fec05b2515ee0)

src/proto_http.c

index 2364bea309e0ca298593b8688cffde40049f2fbc..36d73cef53d6144ea9a52e16b1c3cd5c4e469320 100644 (file)
@@ -4150,6 +4150,7 @@ void manage_server_side_cookies(struct session *t, struct buffer *rtr)
                        if ((asession->sessid = pool_alloc2(apools.sessid)) == NULL) {
                                Alert("Not enough Memory process_srv():asession->sessid:malloc().\n");
                                send_log(t->be, LOG_ALERT, "Not enough Memory process_srv():asession->sessid:malloc().\n");
+                               t->be->htbl_proxy.destroy(asession);
                                return;
                        }
                        memcpy(asession->sessid, t->sessid, t->be->appsession_len);
@@ -4159,6 +4160,7 @@ void manage_server_side_cookies(struct session *t, struct buffer *rtr)
                        if ((asession->serverid = pool_alloc2(apools.serverid)) == NULL) {
                                Alert("Not enough Memory process_srv():asession->sessid:malloc().\n");
                                send_log(t->be, LOG_ALERT, "Not enough Memory process_srv():asession->sessid:malloc().\n");
+                               t->be->htbl_proxy.destroy(asession);
                                return;
                        }
                        asession->serverid[0] = '\0';