diff --git a/src/input/demux.c b/src/input/demux.c
index 466730a21eb9d9e3fb31974ed588bdc44fb04ae4..58c1ae0e681968265314a76b4088dce18d6ebf30 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -608,12 +608,14 @@ static bool SkipAPETag( demux_t *p_demux )
 
 unsigned demux_TestAndClearFlags( demux_t *p_demux, unsigned flags )
 {
-    unsigned i_update;
-    if ( demux_Control( p_demux, DEMUX_TEST_AND_CLEAR_FLAGS, &i_update ) == VLC_SUCCESS )
-        return i_update;
-    unsigned ret = p_demux->info.i_update & flags;
+    unsigned update = flags;
+
+    if ( demux_Control( p_demux, DEMUX_TEST_AND_CLEAR_FLAGS, &update ) == VLC_SUCCESS )
+        return update;
+
+    update = p_demux->info.i_update & flags;
     p_demux->info.i_update &= ~flags;
-    return ret;
+    return update;
 }
 
 int demux_GetTitle( demux_t *p_demux )