Skip to content

Commit 2a54863

Browse files
committed
platform:rtthread:fix memory free to be done before thread exit
Signed-off-by: Ajay Bhargav <ajay.bhargav@waybyte.in>
1 parent b6ff232 commit 2a54863

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

platform/RT-Thread/platform_thread.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ platform_thread_t *platform_thread_init( const char *name,
2828
thread->thread = rt_thread_create((const char *)name,
2929
entry, param,
3030
stack_size, priority, tick);
31-
31+
3232
if (thread->thread == RT_NULL)
3333
{
34-
return RT_NULL;
34+
return RT_NULL;
3535
}
3636
else
3737
{
38-
return thread;
38+
return thread;
3939
}
4040

4141
}
@@ -49,7 +49,6 @@ void platform_thread_startup(platform_thread_t* thread)
4949
void platform_thread_stop(platform_thread_t* thread)
5050
{
5151
rt_thread_suspend(thread->thread);
52-
5352
}
5453

5554
void platform_thread_start(platform_thread_t* thread)
@@ -59,8 +58,9 @@ void platform_thread_start(platform_thread_t* thread)
5958

6059
void platform_thread_destroy(platform_thread_t* thread)
6160
{
62-
rt_thread_delete(thread->thread);
63-
platform_memory_free(thread);
61+
if (thread) {
62+
rt_thread_t thread_handle = thread->thread;
63+
platform_memory_free(thread);
64+
rt_thread_delete(thread_handle);
65+
}
6466
}
65-
66-

0 commit comments

Comments
 (0)