changeset 21563:c08b8066a1c6

Only increase buffer size to avoid crashes when seeking in multi-resolution video files.
author reimar
date Sun, 10 Dec 2006 18:59:28 +0000
parents e655e64087d3
children 6ed90ece4b9b
files libmpcodecs/vd_realvid.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_realvid.c	Sun Dec 10 17:28:56 2006 +0000
+++ b/libmpcodecs/vd_realvid.c	Sun Dec 10 18:59:28 2006 +0000
@@ -60,6 +60,7 @@
 static void *rv_handle=NULL;
 static int inited=0;
 static uint8_t *buffer = NULL;
+static int bufsz = 0;
 #ifdef USE_WIN32DLL
 static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */
 #endif
@@ -300,6 +301,7 @@
 	if (buffer)
 	    free(buffer);
 	buffer = NULL;
+	bufsz = 0;
 }
 
 // copypaste from demux_real.c - it should match to get it working!
@@ -330,9 +332,10 @@
 
 	if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop
 
-	if (!inited) {
+	if (bufsz < sh->disp_w*sh->disp_h*3/2) {
 	    if (buffer) free(buffer);
-	    buffer=malloc(sh->disp_w*sh->disp_h*3/2);
+	    bufsz = sh->disp_w*sh->disp_h*3/2;
+	    buffer=malloc(bufsz);
 	    if (!buffer) return 0;
 	}