diff --git a/libavcodec/options.c b/libavcodec/options.c
index 88b3b12f33d4e03e0755ac89df3ce9475fd4cddd..b31483baa3aefcc343de0199cf0940f607d63b05 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -207,7 +207,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
     alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
     alloc_and_copy_or_fail(rc_override,  src->rc_override_count * sizeof(*src->rc_override), 0);
     alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 1);
-    dest->subtitle_header_size = src->subtitle_header_size;
+    av_assert0(dest->subtitle_header_size == src->subtitle_header_size);
 #undef alloc_and_copy_or_fail
 
     return 0;