diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 41e78daee2b35c321d2fb1b66d4c3fefd798b760..36bc4f9b5104a2aeaac41ee278886cd5af4ff5a4 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1557,13 +1557,21 @@ static int DeinterlaceCallback( vlc_object_t *p_this, char const *psz_cmd,
     {
         psz_filter = realloc( psz_filter, strlen( psz_filter ) +
                               sizeof(":deinterlace") );
-        if( psz_filter && *psz_filter ) strcat( psz_filter, ":" );
-        strcat( psz_filter, "deinterlace" );
+        if( psz_filter )
+        {
+            if( *psz_filter )
+                strcat( psz_filter, ":" );
+            strcat( psz_filter, "deinterlace" );
+        }
     }
 
     p_input = (input_thread_t *)vlc_object_find( p_this, VLC_OBJECT_INPUT,
                                                  FIND_PARENT );
-    if( !p_input ) return VLC_EGENERIC;
+    if( !p_input )
+    {
+        free( psz_filter );
+        return VLC_EGENERIC;
+    }
 
     if( psz_mode && *psz_mode )
     {