]> www.infradead.org Git - users/borneoa/openocd-next.git/commitdiff
rtos: mqx: replace malloc+strcpy with strdup
authorPaul Fertser <fercerpav@gmail.com>
Tue, 26 Nov 2024 20:55:55 +0000 (22:55 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 22 Dec 2024 09:52:20 +0000 (09:52 +0000)
Using strcpy is potentially dangerous so just use a safer and easier way
to do the same.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Change-Id: Id85f3b7f8af1eaf14c9951ae710546d2437c70b5
Reviewed-on: https://review.openocd.org/c/openocd/+/8597
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
src/rtos/mqx.c

index b4a1821352a71c7d557682b7500d8b82857db30c..90154db3fff16745e72461d35adbd8e98d092a23 100644 (file)
@@ -380,10 +380,9 @@ static int mqx_update_threads(
                rtos->thread_details[i].threadid = task_id;
                rtos->thread_details[i].exists = true;
                /* set thread name */
-               rtos->thread_details[i].thread_name_str = malloc(strlen((void *)task_name) + 1);
+               rtos->thread_details[i].thread_name_str = strdup((char *)task_name);
                if (!rtos->thread_details[i].thread_name_str)
                        return ERROR_FAIL;
-               strcpy(rtos->thread_details[i].thread_name_str, (void *)task_name);
                /* set thread extra info
                 * - task state
                 * - task address