Skip to content

Set current thread state to NULL in teardown

In the EGL destructor, DestroyThreadState gets called by __eglCurrentTeardown to free the threadState, but the threadState does not get changed to NULL when this happens.

The function eglReleaseThread calls __eglDestroyCurrentThreadAPIState, which does set the threadState to NULL, right before calling DestroyThreadState. Both eglReleaseThread and __eglDestroyCurrentThreadAPIState check to make sure the threadState is not NULL before continuing.

If eglReleaseThread gets externally called after destruction, the threadState is not NULL, so DestroyThreadState will be called to free the threadState that was already freed by the destructor, causing a double free.

This change is to add the same setting threadState to NULL in __eglCurrentTeardown as which is already in __eglDestroyCurrentThreadAPIState, to prevent this double free situation.

Merge request reports