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
The following commit(s) were added to refs/heads/master by this push:
new 9a1d29272 system/nxplayer: Fix crash on commands without arguments.
9a1d29272 is described below
commit 9a1d292722eedf6f6b5f053fbc3a06904b047646
Author: ViezeVingertjes <[email protected]>
AuthorDate: Wed Nov 25 19:55:07 2026 +0100
system/nxplayer: Fix crash on commands without arguments.
strtok_r() may set the save pointer to NULL when the token ends the
string (POSIX leaves its value unspecified, and e.g. the newlib
implementation in the ESP32-S3 ROM does so). nxplayer then
dereferenced it while skipping leading spaces, so any command without
an argument, such as "q" or "stop", crashed with a NULL pointer load.
Check arg for NULL before dereferencing it, as nxrecorder already does.
Tested on Waveshare ESP32-S3-Touch-AMOLED-2.16: "q" crashed with
LoadProhibited (EXCVADDR 0x0 in nxplayer_main) before, exits cleanly
after.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: ViezeVingertjes <[email protected]>
---
system/nxplayer/nxplayer_main.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/system/nxplayer/nxplayer_main.c b/system/nxplayer/nxplayer_main.c
index af2705388..8d60e0677 100644
--- a/system/nxplayer/nxplayer_main.c
+++ b/system/nxplayer/nxplayer_main.c
@@ -873,9 +873,11 @@ int main(int argc, FAR char *argv[])
continue;
}
- /* Remove leading spaces from arg */
+ /* Remove leading spaces from arg. strtok_r() may set arg to
+ * NULL when the command has no argument (e.g. "q").
+ */
- while (*arg == ' ')
+ while (arg != NULL && *arg == ' ')
{
arg++;
}