changeset 5734:f41a84612842 libavformat

Plug some memory leaks for truncated files
author vitor
date Tue, 02 Mar 2010 21:32:29 +0000
parents 6f9d6b3aae49
children 0f6f55a8e878
files r3d.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/r3d.c	Mon Mar 01 18:16:10 2010 +0000
+++ b/r3d.c	Tue Mar 02 21:32:29 2010 +0000
@@ -212,6 +212,7 @@
     int tmp, tmp2;
     uint64_t pos = url_ftell(s->pb);
     unsigned dts;
+    int ret;
 
     dts = get_be32(s->pb);
 
@@ -243,8 +244,8 @@
     tmp = atom->size - 8 - (url_ftell(s->pb) - pos);
     if (tmp < 0)
         return -1;
-
-    if (av_get_packet(s->pb, pkt, tmp) != tmp) {
+    ret = av_get_packet(s->pb, pkt, tmp);
+    if (ret < 0) {
         av_log(s, AV_LOG_ERROR, "error reading video packet\n");
         return -1;
     }
@@ -265,6 +266,7 @@
     int tmp, tmp2, samples, size;
     uint64_t pos = url_ftell(s->pb);
     unsigned dts;
+    int ret;
 
     dts = get_be32(s->pb);
 
@@ -288,9 +290,10 @@
     size = atom->size - 8 - (url_ftell(s->pb) - pos);
     if (size < 0)
         return -1;
-    if (av_get_packet(s->pb, pkt, size) != size) {
-        av_log(s, AV_LOG_ERROR, "error reading video packet\n");
-        return -1;
+    ret = av_get_packet(s->pb, pkt, size);
+    if (ret < 0) {
+        av_log(s, AV_LOG_ERROR, "error reading audio packet\n");
+        return ret;
     }
 
     pkt->stream_index = 1;