[FFmpeg-devel] [PATCH]Fix possible crash with -threads 0

Carl Eugen Hoyos cehoyos
Tue Nov 23 22:55:18 CET 2010


Hi!

Attached patch seems to fix a crash for some users (see issue 2376) - untested 
on Windows.

Please comment, Carl Eugen
-------------- next part --------------
Index: libavcodec/pthread.c
===================================================================
--- libavcodec/pthread.c	(revision 25813)
+++ libavcodec/pthread.c	(working copy)
@@ -145,11 +145,11 @@
     int i;
     ThreadContext *c;
 
-    avctx->thread_count = thread_count;
-
     if (thread_count <= 1)
         return 0;
 
+    avctx->thread_count = thread_count;
+
     c = av_mallocz(sizeof(ThreadContext));
     if (!c)
         return -1;
Index: libavcodec/w32thread.c
===================================================================
--- libavcodec/w32thread.c	(revision 25813)
+++ libavcodec/w32thread.c	(working copy)
@@ -129,11 +129,11 @@
     ThreadContext *c;
     uint32_t threadid;
 
-    s->thread_count= thread_count;
-
     if (thread_count <= 1)
         return 0;
 
+    s->thread_count= thread_count;
+
     assert(!s->thread_opaque);
     c= av_mallocz(sizeof(ThreadContext)*thread_count);
     s->thread_opaque= c;



More information about the ffmpeg-devel mailing list