[Mplayer-cvslog] CVS: main/libmpdemux cache2.c,1.25,1.26

Ivan Kalvachev CVS syncmail at mplayerhq.hu
Tue Jul 27 00:06:33 CEST 2004


CVS change done by Ivan Kalvachev CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv9300

Modified Files:
	cache2.c 
Log Message:
prevent segfault on shmem failer

Index: cache2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cache2.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- cache2.c	16 Jul 2004 20:31:17 -0000	1.25
+++ cache2.c	26 Jul 2004 22:06:30 -0000	1.26
@@ -196,6 +196,8 @@
 #else
   cache_vars_t* s=malloc(sizeof(cache_vars_t));
 #endif
+  if(s==NULL) return NULL;
+  
   memset(s,0,sizeof(cache_vars_t));
   num=size/sector;
   if(num < 16){
@@ -208,6 +210,16 @@
 #else
   s->buffer=malloc(s->buffer_size);
 #endif
+
+  if(s->buffer == NULL){
+#ifndef WIN32
+    shmem_free(s,sizeof(cache_vars_t));
+#else
+    free(s);
+#endif
+    return NULL;
+  }
+
   s->fill_limit=8*sector;
   s->back_size=s->buffer_size/2;
   return s;
@@ -249,6 +261,7 @@
   }
 
   s=cache_init(size,ss);
+  if(s == NULL) return 0;
   stream->cache_data=s;
   s->stream=stream; // callback
   s->prefill=prefill;




More information about the MPlayer-cvslog mailing list