Commit 503aa397bc for ffmpeg

commit 503aa397bc3f3b4d09358c4a8761621364b379c8
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Wed Nov 11 22:45:24 2026 +0100

    avformat/rtmpdh: do not pass NULL to mpz_clear()

    Fixes: NULL pointer dereference
    Fixes: nFFdUE2kqlXX

    Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25059

    NULL pointer dereference Replicated through Modified FFmpeg with ASAN

diff --git a/libavformat/rtmpdh.c b/libavformat/rtmpdh.c
index fb7aaf07c0..1ed1a52c49 100644
--- a/libavformat/rtmpdh.c
+++ b/libavformat/rtmpdh.c
@@ -66,10 +66,11 @@
         if (bn)                         \
             mpz_init2(bn, 1);           \
     } while (0)
-#define bn_free(bn)     \
-    do {                \
-        mpz_clear(bn);  \
-        av_free(bn);    \
+#define bn_free(bn)         \
+    do {                    \
+        if (bn)             \
+            mpz_clear(bn);  \
+        av_free(bn);        \
     } while (0)
 #define bn_set_word(bn, w)          mpz_set_ui(bn, w)
 #define bn_cmp(a, b)                mpz_cmp(a, b)