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@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