diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 47b708faf9da44336f6caab89839cee18898f31c..bd9a17f4b1f355aa660925b6ab0796472fe98989 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -670,6 +670,7 @@ static void zero_remaining(unsigned int b, unsigned int b_max,
     while (b < b_max)
         count += div_blocks[b];
 
+    if (count)
     memset(buf, 0, sizeof(*buf) * count);
 }