Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/libx265: Pass logctx as void*, not AVClass**
Date: Fri, 22 Mar 2024 14:33:34 +0100
Message-ID: <GV1P250MB07377BACA7FF17BB75BDF9A28F312@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB0737842CEA6E6DCA5F67FFB38F312@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>

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 --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",
                buf);
         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;
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-03-22 13:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 13:32 [FFmpeg-devel] [PATCH 1/2] avcodec/libx265: Don't use AVBPrint unnecessarily Andreas Rheinhardt
2024-03-22 13:33 ` Andreas Rheinhardt [this message]
2024-03-22 13:57 ` [FFmpeg-devel] [PATCH 3/4] avutil/frame: Constify av_frame_side_data_get() Andreas Rheinhardt
2024-03-22 13:58 ` [FFmpeg-devel] [PATCH 4/4] avutil/frame: Rename av_frame_side_data_get and add wrapper for it Andreas Rheinhardt
2024-03-22 14:41 ` [FFmpeg-devel] [PATCH 5/5] avutil/frame: Use av_realloc_array(), improve overflow check Andreas Rheinhardt
2024-03-22 22:07   ` Jan Ekström

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=GV1P250MB07377BACA7FF17BB75BDF9A28F312@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git