fix pthread_cleanup_pop(1) crash in non-thread-capable, static-linked programs
authorRich Felker <dalias@aerifal.cx>
Tue, 28 Feb 2012 15:13:35 +0000 (10:13 -0500)
committerRich Felker <dalias@aerifal.cx>
Tue, 28 Feb 2012 15:13:35 +0000 (10:13 -0500)
src/thread/cancellation.c
src/thread/pthread_create.c

index 23d23d1..ab7eebc 100644 (file)
@@ -5,6 +5,8 @@ void __do_cleanup_pop();
 
 void _pthread_cleanup_push(struct __ptcb *cb, void (*f)(void *), void *x)
 {
 
 void _pthread_cleanup_push(struct __ptcb *cb, void (*f)(void *), void *x)
 {
+       cb->__f = f;
+       cb->__x = x;
        __do_cleanup_push(cb, f, x);
 }
 
        __do_cleanup_push(cb, f, x);
 }
 
index d84e50a..0e1dbb2 100644 (file)
@@ -46,8 +46,6 @@ void pthread_exit(void *result)
 void __do_cleanup_push(struct __ptcb *cb, void (*f)(void *), void *x)
 {
        struct pthread *self = pthread_self();
 void __do_cleanup_push(struct __ptcb *cb, void (*f)(void *), void *x)
 {
        struct pthread *self = pthread_self();
-       cb->__f = f;
-       cb->__x = x;
        cb->__next = self->cancelbuf;
        self->cancelbuf = cb;
 }
        cb->__next = self->cancelbuf;
        self->cancelbuf = cb;
 }