[FFmpeg-devel] [PATCH 11/12] avcodec/sanm: change GetByteContext member to pointer
Michael Niedermayer
michael at niedermayer.cc
Fri Mar 14 22:31:00 EET 2025
Hi Manuel
On Thu, Mar 13, 2025 at 12:15:04PM +0100, Manuel Lauss wrote:
> In order do properly support the ANIM STOR/FTCH system, the FTCH
> must replay a stored FOBJ and change the SANMContext's "GetByteContext"
> member temporarily.
>
> Signed-off-by: Manuel Lauss <manuel.lauss at gmail.com>
> ---
> libavcodec/sanm.c | 394 +++++++++++++++++++++++-----------------------
> 1 file changed, 198 insertions(+), 196 deletions(-)
>
> diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
> index a8a3e04156..207db4a8fb 100644
> --- a/libavcodec/sanm.c
> +++ b/libavcodec/sanm.c
[...]
> @@ -2114,10 +2114,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
> int *got_frame_ptr, AVPacket *pkt)
> {
> SANMVideoContext *ctx = avctx->priv_data;
> + GetByteContext gb;
> int i, ret;
>
> ctx->frame = frame;
> - bytestream2_init(&ctx->gb, pkt->data, pkt->size);
> + bytestream2_init(&gb, pkt->data, pkt->size);
> + ctx->gb = &gb;
Having a context pointer point to the local stack is fragile
Because the context and pointer have a longer lifetime than the stack
So for a long portion of the time this pointer is totally invalid
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250314/260db2de/attachment.sig>
More information about the ffmpeg-devel
mailing list