BUILD: debug: Avoid warnings in dev mode with -02 because of some BUG_ON tests

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.

(cherry picked from commit ea009736d8f25be6c79aff0bed3a994eef87f3fd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/hlua.c b/src/hlua.c
index cb5feb5..5f5b2c3 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -3957,7 +3957,7 @@
 		int32_t pos;
 
 		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. */
diff --git a/src/mux_h2.c b/src/mux_h2.c
index a0fb93d..fd039d1 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -4586,7 +4586,7 @@
 
 	/* 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;
@@ -4795,7 +4795,7 @@
 
 	/* 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);
diff --git a/src/stats.c b/src/stats.c
index 0a0ed1d..e04ae92 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -283,7 +283,7 @@
 		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));
 		p = uri.ptr;