[MPlayer-dev-eng] [patch] cache2.c: when fork() fails, mplayer can kill every user process
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Tue Jan 19 21:55:42 CET 2010
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cache.diff
Type: text/x-diff
Size: 1466 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20100119/2574d4a6/attachment.diff>
More information about the MPlayer-dev-eng
mailing list