diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 07aff923ba90d880af97cd67aadd8ed70e392716..58072d49ba256731a04219b17ec230a9598b8cad 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1438,7 +1438,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
         }
         if (s->fileversion < 3950) // previous versions overread two bytes
             buf_size += 2;
-        av_fast_malloc(&s->data, &s->data_size, buf_size);
+        av_fast_padded_malloc(&s->data, &s->data_size, buf_size);
         if (!s->data)
             return AVERROR(ENOMEM);
         s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);