[MPlayer-dev-eng] [patch] cache2.c: when fork() fails, mplayer can kill every user process

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Jan 23 12:19:19 CET 2010


On Wed, Jan 20, 2010 at 03:43:49AM +0300, Yuriy Kaminskiy wrote:
> On 19.01.2010 23:55, Reimar Döffinger wrote:
> > On Tue, Jan 19, 2010 at 06:26:19PM +0300, Yuriy Kaminskiy wrote:
> >> Index: MPlayer/stream/cache2.c
> >> ===================================================================
> >> --- MPlayer.orig/stream/cache2.c	2010-01-19 17:56:38.000000000 +0300
> >> +++ MPlayer/stream/cache2.c	2010-01-19 18:04:03.000000000 +0300
> >> @@ -333,7 +333,17 @@ int stream_enable_cache(stream_t *stream
> >>    }
> >>  
> >>  #if !defined(__MINGW32__) && !defined(PTHREAD_CACHE) && !defined(__OS2__)
> >> -  if((stream->cache_pid=fork())){
> >> +  {
> >> +    pid_t pid = fork();
> >> +    if (pid < 0) {
> >> +      shmem_free(s->buffer,s->buffer_size);
> >> +      shmem_free(stream->cache_data,sizeof(cache_vars_t));
> >> +      stream->cache_data = NULL;
> >> +      return 0;
> >> +    }
> >> +    stream->cache_pid=pid;
> >> +  }
> >> +  if (stream->cache_pid){
> >>  #else
> > 
> > Freeing really doesn't belong here.
> > You could test if something like the attached, completely untested patch works.
> 
> Don't have appropriate environment for testing, so, uhm.
> Anyway, your patch clearly did not fixed this bug.

Sorry about that, I applied some mixture of different things.
I you know of something that still doesn't work please report it.



More information about the MPlayer-dev-eng mailing list