diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index c1f354e0dbe0e27354b427e61441c5712cf38736..5267b25f2fd787ae7c37187514c8f54da501e380 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -2540,6 +2540,8 @@ static int alloc_tables(H264Context *h){
         }
     }
 
+    s->obmc_scratchpad = NULL;
+
     return 0;
 fail:
     free_tables(h);