[FREELDR] Skip NULL-pointer entries in Argv when enumerating arguments.

A NULL pointer (not necessarily the terminating one) is a valid entry
in the Argv argument vector, according to the ARC specification
(Section 4.4 "Loaded-Program Conventions").
Thus, such pointer needs to be ignored when searching over the
argument vector.
This commit is contained in:
Hermès Bélusca-Maïto 2024-04-05 17:44:43 +02:00
parent 93245d385d
commit c044201472
No known key found for this signature in database
GPG Key ID: 3B2539C65E7B93D0
1 changed files with 4 additions and 3 deletions

View File

@ -23,9 +23,10 @@ GetNextArgumentValue(
for (i = (LastIndex ? *LastIndex : 0); i < Argc; ++i)
{
if (strlen(Argv[i]) >= ArgNameLen + 1 /* Count the '=' sign */ &&
_strnicmp(Argv[i], ArgumentName, ArgNameLen) == 0 &&
Argv[i][ArgNameLen] == '=')
if (Argv[i] /* NULL pointer is a valid entry in Argv: skip it */ &&
(strlen(Argv[i]) >= ArgNameLen + 1 /* Count the '=' sign */) &&
(_strnicmp(Argv[i], ArgumentName, ArgNameLen) == 0) &&
(Argv[i][ArgNameLen] == '='))
{
/* Found it, return the value */
if (LastIndex) *LastIndex = i;