]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: httpclient/cli: change the appctx test in the callbacks
authorWilliam Lallemand <wlallemand@haproxy.org>
Fri, 20 Aug 2021 09:35:29 +0000 (11:35 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 20 Aug 2021 09:53:16 +0000 (11:53 +0200)
The callbacks of the CLI httpclient are testing the appctx pointer
before doing the appctx_wakeup but was dereferencing the appctx pointer
before.

src/http_client.c

index 7e950f96cb08426f0312e79fc3891e3a13de2b9e..89d7d766729646b87addbb4cbc6db444d4e0b315 100644 (file)
@@ -64,36 +64,44 @@ void hc_cli_res_stline_cb(struct httpclient *hc)
 {
        struct appctx *appctx = hc->caller;
 
+       if (!appctx)
+               return;
+
        appctx->ctx.cli.i0 |= HC_CLI_F_RES_STLINE;
-       if (appctx)
-               appctx_wakeup(appctx);
+       appctx_wakeup(appctx);
 }
 
 void hc_cli_res_headers_cb(struct httpclient *hc)
 {
        struct appctx *appctx = hc->caller;
 
+       if (!appctx)
+               return;
+
        appctx->ctx.cli.i0 |= HC_CLI_F_RES_HDR;
-       if (appctx)
-               appctx_wakeup(appctx);
+       appctx_wakeup(appctx);
 }
 
 void hc_cli_res_body_cb(struct httpclient *hc)
 {
        struct appctx *appctx = hc->caller;
 
+       if (!appctx)
+               return;
+
        appctx->ctx.cli.i0 |= HC_CLI_F_RES_BODY;
-       if (appctx)
-               appctx_wakeup(appctx);
+       appctx_wakeup(appctx);
 }
 
 void hc_cli_res_end_cb(struct httpclient *hc)
 {
        struct appctx *appctx = hc->caller;
 
+       if (!appctx)
+               return;
+
        appctx->ctx.cli.i0 |= HC_CLI_F_RES_END;
-       if (appctx)
-               appctx_wakeup(appctx);
+       appctx_wakeup(appctx);
 }
 
 /*