diff --git a/src/system/libroot/posix/pthread/pthread_cleanup.cpp b/src/system/libroot/posix/pthread/pthread_cleanup.cpp index eae1f4d9d7..36b86c0c8d 100644 --- a/src/system/libroot/posix/pthread/pthread_cleanup.cpp +++ b/src/system/libroot/posix/pthread/pthread_cleanup.cpp @@ -27,8 +27,10 @@ __pthread_cleanup_pop_handler(void) return NULL; __pthread_cleanup_handler* handler = thread->cleanup_handlers; - thread->cleanup_handlers = handler->previous; + if (handler == NULL) + return NULL; + thread->cleanup_handlers = handler->previous; return handler; }