# HG changeset patch # User iive # Date 1090879590 0 # Node ID 061dd89b6a23b2ceab742216ba0027c78b9eb7b8 # Parent 2054ffe13177042dfb0184adcf37dc0e82573cf9 prevent segfault on shmem failer diff -r 2054ffe13177 -r 061dd89b6a23 libmpdemux/cache2.c --- a/libmpdemux/cache2.c Mon Jul 26 00:52:56 2004 +0000 +++ b/libmpdemux/cache2.c Mon Jul 26 22:06:30 2004 +0000 @@ -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;