From: Aurelien DARRAGON Date: Tue, 30 Apr 2024 06:55:13 +0000 (+0200) Subject: MINOR: log/cbor: _lf_cbor_encode_byte() explicitly requires non-NULL ctx (again) X-Git-Tag: v3.0-dev10~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=41d7e82e0f92e7fc17ed26496337d4a9f0dca95c;p=thirdparty%2Fhaproxy.git MINOR: log/cbor: _lf_cbor_encode_byte() explicitly requires non-NULL ctx (again) The BUG_ON() statement that was added in 9bdea51 ("MINOR: log/cbor: _lf_cbor_encode_byte() explicitly requires non-NULL ctx") isn't sufficient as Coverity still thinks the lf_buildctx itself may be NULL as shown in GH #2554. In fact the original reports complains about the lf_buildctx itself and I didn't understand it properly, let's add another check in the BUG_ON() to ensure both cbor_ctx and cbor_ctx->ctx are not NULL since it is not expected if used properly. --- diff --git a/src/log.c b/src/log.c index ee22e94ac1..4ff4e3ad4a 100644 --- a/src/log.c +++ b/src/log.c @@ -1794,7 +1794,7 @@ static char *_lf_cbor_encode_byte(struct cbor_encode_ctx *cbor_ctx, { struct lf_buildctx *ctx; - BUG_ON(!cbor_ctx); + BUG_ON(!cbor_ctx || !cbor_ctx->e_fct_ctx); ctx = cbor_ctx->e_fct_ctx; if (ctx->options & LOG_OPT_BIN) {