]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/flac_picture.c
Merge commit 'ddc589ce98c2bba1e59318b5b0224717325eac46'
[ffmpeg] / libavformat / flac_picture.c
index 69d27244fff4caffdb6e9e6a6ba2ed604e23f366..12d73e488f97c055838b66e107156527a4991495 100644 (file)
@@ -1,23 +1,25 @@
 /*
  * Raw FLAC picture parser
+ * Copyright (c) 2001 Fabrice Bellard
  *
- * 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
  */
 
+#include "libavutil/avassert.h"
 #include "avformat.h"
 #include "flac_picture.h"
 #include "id3v2.h"
@@ -43,8 +45,7 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
     if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) {
         av_log(s, AV_LOG_ERROR, "Invalid picture type: %d.\n", type);
         if (s->error_recognition & AV_EF_EXPLODE) {
-            ret = AVERROR_INVALIDDATA;
-            goto fail;
+            RETURN_ERROR(AVERROR_INVALIDDATA);
         }
         type = 0;
     }
@@ -59,6 +60,7 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
             ret = AVERROR_INVALIDDATA;
         goto fail;
     }
+    av_assert0(len < sizeof(mimetype));
     mimetype[len] = 0;
 
     while (mime->id != AV_CODEC_ID_NONE) {
@@ -80,8 +82,7 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
     len = avio_rb32(pb);
     if (len > 0) {
         if (!(desc = av_malloc(len + 1))) {
-            ret = AVERROR(ENOMEM);
-            goto fail;
+            RETURN_ERROR(AVERROR(ENOMEM));
         }
 
         if (avio_read(pb, desc, len) != len) {
@@ -107,8 +108,7 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
         goto fail;
     }
     if (!(data = av_buffer_alloc(len))) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
+        RETURN_ERROR(AVERROR(ENOMEM));
     }
     if (avio_read(pb, data->data, len) != len) {
         av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n");
@@ -119,8 +119,7 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
 
     st = avformat_new_stream(s, NULL);
     if (!st) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
+        RETURN_ERROR(AVERROR(ENOMEM));
     }
 
     av_init_packet(&st->attached_pic);