ustreamer: options: NULL-terminate the copy of argv (#322)

According to N2176 of ISO/IEC 9899:2017 §5.1.2.2.1 ¶2:

> - argv[argc] shall be a null pointer.

Possibly fixes openwrt/packages#28472.
This commit is contained in:
Ivan Shapovalov 2026-02-03 18:41:40 +01:00 committed by GitHub
parent 15a9e28ac6
commit 614e83771b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -300,10 +300,11 @@ us_options_s *us_options_init(uint argc, char *argv[]) {
opts->argc = argc; opts->argc = argc;
opts->argv = argv; opts->argv = argv;
US_CALLOC(opts->argv_copy, argc); US_CALLOC(opts->argv_copy, argc + 1);
for (uint i = 0; i < argc; ++i) { for (uint i = 0; i < argc; ++i) {
opts->argv_copy[i] = us_strdup(argv[i]); opts->argv_copy[i] = us_strdup(argv[i]);
} }
opts->argv_copy[argc] = NULL;
return opts; return opts;
} }