Avoid divisions by 0 in the ASF demuxer if packet_size is not valid.
authorReinhard Tartler <siretart@tauware.de>
Fri, 26 Feb 2010 15:49:52 +0000 (15:49 +0000)
committerReinhard Tartler <siretart@tauware.de>
Fri, 26 Feb 2010 15:49:52 +0000 (15:49 +0000)
r19330 by reimar

Originally committed as revision 22080 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5

libavformat/asfdec.c

index 4d61739..cb695c1 100644 (file)
@@ -555,7 +555,9 @@ int ff_asf_get_packet(AVFormatContext *s, ByteIOContext *pb)
     int rsize = 8;
     int c, d, e, off;
 
-    off= (url_ftell(pb) - s->data_offset) % asf->packet_size + 3;
+    off= 32768;
+    if (s->packet_size > 0)
+        off= (url_ftell(pb) - s->data_offset) % asf->packet_size + 3;
 
     c=d=e=-1;
     while(off-- > 0){
@@ -941,7 +943,8 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos,
         start_pos[i]= pos;
     }
 
-    pos= (pos+asf->packet_size-1-s->data_offset)/asf->packet_size*asf->packet_size+ s->data_offset;
+    if (s->packet_size > 0)
+        pos= (pos+asf->packet_size-1-s->data_offset)/asf->packet_size*asf->packet_size+ s->data_offset;
     *ppos= pos;
     url_fseek(s->pb, pos, SEEK_SET);