Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dangling pointer in component pthread and dfs_elm #9976

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[components/libc/posix][pthreads]fix the risk of dangling pointer
  • Loading branch information
lingfengPeng committed Jan 16, 2025
commit 0fd8976d1954c14320eafa3d8dab072535eb5c94
6 changes: 3 additions & 3 deletions components/libc/posix/pthreads/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ void _pthread_data_destroy(_pthread_data_t *ptd)
/* clean magic */
ptd->magic = 0x0;

/* clear the "ptd->tid->pthread_data" */
ptd->tid->pthread_data = RT_NULL;

/* free ptd */
rt_free(ptd);
}
Expand All @@ -185,6 +182,9 @@ static void _pthread_cleanup(rt_thread_t tid)
/* restore tid stack */
rt_free(tid->stack_addr);

/* clear the "ptd->tid->pthread_data" */
tid->pthread_data = RT_NULL;

/* restore tid control block */
rt_free(tid);
}
Expand Down