Skip to content

Commit b6ff232

Browse files
committed
platform:FreeRTOS:fix memory cannot be freed once task exits
Task handle must be storead in temporary variable and then memory is to be freed. Else task exits before memory free is executed. Signed-off-by: Ajay Bhargav <ajay.bhargav@waybyte.in>
1 parent c869ebb commit b6ff232

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

platform/FreeRTOS/platform_thread.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ platform_thread_t *platform_thread_init( const char *name,
1717
{
1818
BaseType_t err;
1919
platform_thread_t *thread;
20-
20+
2121
thread = platform_memory_alloc(sizeof(platform_thread_t));
2222

2323
(void)tick;
@@ -50,10 +50,11 @@ void platform_thread_start(platform_thread_t* thread)
5050

5151
void platform_thread_destroy(platform_thread_t* thread)
5252
{
53-
if (NULL != thread)
54-
vTaskDelete(thread->thread);
55-
56-
platform_memory_free(thread);
57-
}
53+
if (NULL != thread) {
54+
TaskHandle_t thread_handle = thread->thread;
5855

56+
platform_memory_free(thread);
5957

58+
vTaskDelete(thread_handle);
59+
}
60+
}

0 commit comments

Comments
 (0)