From ac33a4e14fb08e711f032bb7a880e0ef6638cb6e Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Wed, 18 Mar 2026 11:15:45 +0800 Subject: [PATCH] system/nxrecorder: Fix null pointer dereference in argument parsing When a command has no arguments (e.g., 'q', 'quit', 'stop'), the strtok_r() function returns NULL for the arg parameter. The argument trimming loop was dereferencing this NULL pointer without checking, causing undefined behavior and system hang on ESP32-S3. This commit adds a null check before dereferencing the arg pointer in the leading space trimming loop. Tested on ESP32-S3 (lckfb-szpi-esp32s3) - quit command now works correctly. Signed-off-by: wangjianyu3 --- system/nxrecorder/nxrecorder_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/nxrecorder/nxrecorder_main.c b/system/nxrecorder/nxrecorder_main.c index 8ba3ad4b494..a8a4c63d67c 100644 --- a/system/nxrecorder/nxrecorder_main.c +++ b/system/nxrecorder/nxrecorder_main.c @@ -588,7 +588,7 @@ int main(int argc, FAR char *argv[]) /* Remove leading spaces from arg */ - while (*arg == ' ') + while (arg && *arg == ' ') { arg++; }