diff mbox series

[FFmpeg-devel,2/2] avcodec/libx265: Pass logctx as void*, not AVClass**

Message ID GV1P250MB07377BACA7FF17BB75BDF9A28F312@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit b9fcc135c570e254b8cb8d63c50877646bf97e40
Headers show
Series [FFmpeg-devel,1/2] avcodec/libx265: Don't use AVBPrint unnecessarily | expand


Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt March 22, 2024, 1:33 p.m. UTC
The latter need not be save, because av_log() expects
to get a pointer to an AVClass-enabled structure
and not only a fake object. If this function were actually
be called in the following way:

const AVClass *avcl = avctx->av_class;
handle_mdcv(&avcl, );

the AVClass's item_name would expect to point to an actual
AVCodecContext, potentially leading to a segfault.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
 libavcodec/libx265.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series


diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index d7620878b8..45349a85b9 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -175,7 +175,7 @@  static av_cold int libx265_param_parse_int(AVCodecContext *avctx,
     return 0;
-static int handle_mdcv(const AVClass **avcl, const x265_api *api,
+static int handle_mdcv(void *logctx, const x265_api *api,
                        x265_param *params,
                        const AVMasteringDisplayMetadata *mdcv)
@@ -198,7 +198,7 @@  static int handle_mdcv(const AVClass **avcl, const x265_api *api,
     if (api->param_parse(params, "master-display", buf) ==
             X265_PARAM_BAD_VALUE) {
-        av_log(avcl, AV_LOG_ERROR,
+        av_log(logctx, AV_LOG_ERROR,
                "Invalid value \"%s\" for param \"master-display\".\n",
         return AVERROR(EINVAL);
@@ -230,7 +230,7 @@  static int handle_side_data(AVCodecContext *avctx, const x265_api *api,
     if (mdcv_sd) {
         int ret = handle_mdcv(
-            &avctx->av_class, api, params,
+            avctx, api, params,
             (AVMasteringDisplayMetadata *)mdcv_sd->data);
         if (ret < 0)
             return ret;