[FFmpeg-devel] [PATCH 1/2] avformat/oggparsevorbis: use the base64 decode size macro

James Almer jamrial at gmail.com
Fri Jun 17 00:30:40 CEST 2016


Allocate the memory needed for the decoded data rather than the
encoded data.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/oggparsevorbis.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index a8cd6c9..c168718 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -152,8 +152,8 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
              * recommended way of embedding cover art within VorbisComments."
              */
             if (!strcmp(tt, "METADATA_BLOCK_PICTURE") && parse_picture) {
-                int ret;
-                char *pict = av_malloc(vl);
+                int ret, len = AV_BASE64_DECODE_SIZE(vl);
+                char *pict = av_malloc(len);
 
                 if (!pict) {
                     av_log(as, AV_LOG_WARNING, "out-of-memory error. Skipping cover art block.\n");
@@ -161,7 +161,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
                     av_freep(&ct);
                     continue;
                 }
-                if ((ret = av_base64_decode(pict, ct, vl)) > 0)
+                if ((ret = av_base64_decode(pict, ct, len)) > 0)
                     ret = ff_flac_parse_picture(as, pict, ret);
                 av_freep(&tt);
                 av_freep(&ct);
-- 
2.8.2



More information about the ffmpeg-devel mailing list