Skip to content

Commit 0fd8976

Browse files
committed
[components/libc/posix][pthreads]fix the risk of dangling pointer
1 parent d3841c3 commit 0fd8976

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

components/libc/posix/pthreads/pthread.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@ void _pthread_data_destroy(_pthread_data_t *ptd)
169169
/* clean magic */
170170
ptd->magic = 0x0;
171171

172-
/* clear the "ptd->tid->pthread_data" */
173-
ptd->tid->pthread_data = RT_NULL;
174-
175172
/* free ptd */
176173
rt_free(ptd);
177174
}
@@ -185,6 +182,9 @@ static void _pthread_cleanup(rt_thread_t tid)
185182
/* restore tid stack */
186183
rt_free(tid->stack_addr);
187184

185+
/* clear the "ptd->tid->pthread_data" */
186+
tid->pthread_data = RT_NULL;
187+
188188
/* restore tid control block */
189189
rt_free(tid);
190190
}

0 commit comments

Comments
 (0)