This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix pthread_create


Hi!

If
      if (pd->schedparam.sched_priority < minprio
          || pd->schedparam.sched_priority > maxprio)
        {
          err = EINVAL;
          goto errout;
        }
jumps to errout, is_detached, which is not in scope at this
point, will have undefined value.  I guess we want to deallocate
the stack always if create_thread has not been called.

2004-10-28  Jakub Jelinek  <jakub@redhat.com>

	* pthread_create.c (__pthread_create_2_1): Avoid leaking stacks
	if sched_priority is not between minprio and maxprio.

--- libc/nptl/pthread_create.c.jj	2004-09-30 00:50:02.000000000 +0200
+++ libc/nptl/pthread_create.c	2004-10-28 17:31:51.016851090 +0200
@@ -459,10 +459,12 @@ __pthread_create_2_1 (newthread, attr, s
   err = create_thread (pd, iattr, STACK_VARIABLES_ARGS);
   if (err != 0)
     {
-    errout:
       /* Something went wrong.  Free the resources.  */
       if (!is_detached)
-	__deallocate_stack (pd);
+	{
+    errout:
+	  __deallocate_stack (pd);
+	}
       return err;
     }
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]