Mercurial > mplayer.hg
changeset 12899:061dd89b6a23
prevent segfault on shmem failer
author | iive |
---|---|
date | Mon, 26 Jul 2004 22:06:30 +0000 |
parents | 2054ffe13177 |
children | a5df08927328 |
files | libmpdemux/cache2.c |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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;