]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: debug: Avoid warnings in dev mode with -02 because of some BUG_ON tests
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 18 Nov 2019 14:50:25 +0000 (15:50 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Nov 2019 13:11:47 +0000 (14:11 +0100)
Some BUG_ON() tests emit a warning because of a potential null pointer
dereference on an HTX block. In fact, it should never happen, but now, GCC is
happy.

This patch must be backported to 2.0.

src/hlua.c
src/mux_h2.c
src/stats.c

index cefaf3801417958100ade92300eeb44508dbcb97..37f7866874a2e25df43727df42fce6898ee7e36f 100644 (file)
@@ -3911,7 +3911,7 @@ static int hlua_applet_http_new(lua_State *L, struct appctx *ctx)
 
        htx = htxbuf(&s->req.buf);
        blk = htx_get_first_blk(htx);
-       BUG_ON(htx_get_blk_type(blk) != HTX_BLK_REQ_SL);
+       BUG_ON(!blk || htx_get_blk_type(blk) != HTX_BLK_REQ_SL);
        sl = htx_get_blk_ptr(htx, blk);
 
        /* Stores the request method. */
index 49e0a2fac3efdb164fe1ef4330290eb5731f7876..24543458b72bdace3fda38e89ea8991de4cd5e5f 100644 (file)
@@ -4629,7 +4629,7 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, struct htx *htx)
 
        /* get the start line, we do have one */
        blk = htx_get_head_blk(htx);
-       BUG_ON(htx_get_blk_type(blk) != HTX_BLK_RES_SL);
+       BUG_ON(!blk || htx_get_blk_type(blk) != HTX_BLK_RES_SL);
        ALREADY_CHECKED(blk);
        sl = htx_get_blk_ptr(htx, blk);
        h2s->status = sl->info.res.status;
@@ -4864,7 +4864,7 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
 
        /* get the start line, we do have one */
        blk = htx_get_head_blk(htx);
-       BUG_ON(htx_get_blk_type(blk) != HTX_BLK_REQ_SL);
+       BUG_ON(!blk || htx_get_blk_type(blk) != HTX_BLK_REQ_SL);
        ALREADY_CHECKED(blk);
        sl = htx_get_blk_ptr(htx, blk);
        meth = htx_sl_req_meth(sl);
index 02057c59289c64e83b2449aa02194c73df40650f..5954fe67f88f8dda0a4e260bc9327e8fb349427e 100644 (file)
@@ -284,7 +284,7 @@ static const char *stats_scope_ptr(struct appctx *appctx, struct stream_interfac
        struct ist uri;
 
        blk = htx_get_head_blk(htx);
-       BUG_ON(htx_get_blk_type(blk) != HTX_BLK_REQ_SL);
+       BUG_ON(!blk || htx_get_blk_type(blk) != HTX_BLK_REQ_SL);
        ALREADY_CHECKED(blk);
        uri = htx_sl_req_uri(htx_get_blk_ptr(htx, blk));
        return uri.ptr + appctx->ctx.stats.scope_str;