]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix leak on pthread failures.
authorMichael Jerris <mike@jerris.com>
Mon, 21 May 2007 15:38:35 +0000 (15:38 +0000)
committerMichael Jerris <mike@jerris.com>
Mon, 21 May 2007 15:38:35 +0000 (15:38 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@61 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/zap_threadmutex.c

index baea9bcbf1af9763173635bb01d55d5eda347d68..8fc4632fd3b91bdf1aebe97ef12966a7f9f6db6c 100644 (file)
@@ -104,19 +104,24 @@ zap_status_t zap_thread_create_detached_ex(zap_thread_function_t func, void *dat
                goto fail;
        }
        CloseHandle(thread->handle);
+
+       status = ZAP_SUCCESS;
+       goto done;
 #else
        
        if (pthread_attr_init(&thread->attribute) != 0) goto fail;
 
-       if (pthread_attr_setdetachstate(&thread->attribute, PTHREAD_CREATE_DETACHED) != 0) goto fail;
+       if (pthread_attr_setdetachstate(&thread->attribute, PTHREAD_CREATE_DETACHED) != 0) goto failpthread;
 
-       if (thread->stack_size && pthread_attr_setstacksize(&thread->attribute, thread->stack_size) != 0) goto fail;
+       if (thread->stack_size && pthread_attr_setstacksize(&thread->attribute, thread->stack_size) != 0) goto failpthread;
 
-       if (pthread_create(&thread->handle, &thread->attribute, thread_launch, thread) != 0) goto fail;
+       if (pthread_create(&thread->handle, &thread->attribute, thread_launch, thread) != 0) goto failpthread;
 
-#endif
        status = ZAP_SUCCESS;
        goto done;
+failpthread:
+       pthread_attr_destroy(&thread->attribute);
+#endif
 
 fail:
        if (thread) {