This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 817f6c1d3162c08874255915075e3f1ae960ef99
Author: caifan3 <[email protected]>
AuthorDate: Wed Aug 27 11:37:30 2025 +0800

    nxplayer: check pthread_attr_init() and release the attributes
    
    The play thread attributes are set up without checking the result of
    pthread_attr_init(), and the attribute object is never destroyed.
    
    Report the failure and leave through the error path, and destroy the
    attributes after the thread has been created.
    
    Signed-off-by: caifan3 <[email protected]>
---
 system/nxplayer/nxplayer.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/system/nxplayer/nxplayer.c b/system/nxplayer/nxplayer.c
index 3cea30093..cfe8fcdf3 100644
--- a/system/nxplayer/nxplayer.c
+++ b/system/nxplayer/nxplayer.c
@@ -2085,7 +2085,13 @@ static int nxplayer_playinternal(FAR struct nxplayer_s 
*pplayer,
    * audio device.
    */
 
-  pthread_attr_init(&tattr);
+  ret = pthread_attr_init(&tattr);
+  if (ret != OK)
+    {
+      auderr("ERROR: Failed to init playthread: %d\n", ret);
+      goto err_out;
+    }
+
   sparam.sched_priority = sched_get_priority_max(SCHED_FIFO) - 9;
   pthread_attr_setschedparam(&tattr, &sparam);
   pthread_attr_setstacksize(&tattr,
@@ -2099,6 +2105,7 @@ static int nxplayer_playinternal(FAR struct nxplayer_s 
*pplayer,
   nxplayer_reference(pplayer);
   ret = pthread_create(&pplayer->play_id, &tattr, nxplayer_playthread,
                        (pthread_addr_t) pplayer);
+  pthread_attr_destroy(&tattr);
   if (ret != OK)
     {
       auderr("ERROR: Failed to create playthread: %d\n", ret);

Reply via email to