]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mace.c
fraps: check overread per sample instead of per line
[ffmpeg] / libavcodec / mace.c
index 5e870a2d2ef96bbe98d590c6967e8fc24f788f0a..980ebb90277d1ee5251afd74255ec9aae61631cf 100644 (file)
@@ -2,20 +2,20 @@
  * MACE decoder
  * Copyright (c) 2002 Laszlo Torok <torokl@alpha.dfmk.hu>
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -243,11 +243,14 @@ static int mace_decode_frame(AVCodecContext *avctx,
     int16_t *samples = data;
     MACEContext *ctx = avctx->priv_data;
     int i, j, k, l;
+    int out_size;
     int is_mace3 = (avctx->codec_id == CODEC_ID_MACE3);
 
-    if (*data_size < (3 * buf_size << (2-is_mace3))) {
-        av_log(avctx, AV_LOG_ERROR, "Output buffer too small!\n");
-        return -1;
+    out_size = 3 * (buf_size << (1 - is_mace3)) *
+               av_get_bytes_per_sample(avctx->sample_fmt);
+    if (*data_size < out_size) {
+        av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
+        return AVERROR(EINVAL);
     }
 
     for(i = 0; i < avctx->channels; i++) {
@@ -274,7 +277,7 @@ static int mace_decode_frame(AVCodecContext *avctx,
             }
     }
 
-    *data_size = 3 * buf_size << (2-is_mace3);
+    *data_size = out_size;
 
     return buf_size;
 }