[FFmpeg-cvslog] avformat/oggdec/ogg_read_packet(): factorize failure code path

Michael Niedermayer git at videolan.org
Sun Apr 6 18:24:45 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Apr  6 17:09:32 2014 +0200| [4ccd7cb45b9aa46d94c29dbd1c065b652bda2319] | committer: Michael Niedermayer

avformat/oggdec/ogg_read_packet(): factorize failure code path

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ccd7cb45b9aa46d94c29dbd1c065b652bda2319
---

 libavformat/oggdec.c |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index b969537..2a2be2a 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -793,11 +793,8 @@ retry:
         uint8_t *side_data = av_packet_new_side_data(pkt,
                                                      AV_PKT_DATA_SKIP_SAMPLES,
                                                      10);
-        if(side_data == NULL) {
-            av_free_packet(pkt);
-            av_free(pkt);
-            return AVERROR(ENOMEM);
-        }
+        if(side_data == NULL)
+            goto fail;
         AV_WL32(side_data + 4, os->end_trimming);
         os->end_trimming = 0;
     }
@@ -806,17 +803,19 @@ retry:
         uint8_t *side_data = av_packet_new_side_data(pkt,
                                                      AV_PKT_DATA_METADATA_UPDATE,
                                                      os->new_metadata_size);
-        if(side_data == NULL) {
-            av_free_packet(pkt);
-            av_free(pkt);
-            return AVERROR(ENOMEM);
-        }
+        if(side_data == NULL)
+            goto fail;
+
         memcpy(side_data, os->new_metadata, os->new_metadata_size);
         av_freep(&os->new_metadata);
         os->new_metadata_size = 0;
     }
 
     return psize;
+fail:
+    av_free_packet(pkt);
+    av_free(pkt);
+    return AVERROR(ENOMEM);
 }
 
 static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,



More information about the ffmpeg-cvslog mailing list