Skip to content

Commit

Permalink
ShellPkg: Fix check on OldArgv in UpdateArgcArgv()
Browse files Browse the repository at this point in the history
The UpdateArgcArgv() function documentation says "If OldArgv or OldArgc
is NULL then that value is not returned."

However, only OldArgc was checked for NULL, probably because of
copy-pasto. In case OldArgc was non-NULL, but OldArgv was null, it could
cause a segmentation fault.

Check OldArgv is not NULL before dereferencing the value.

Signed-off-by: Tormod Volden <[email protected]>
  • Loading branch information
tormodvolden committed Nov 24, 2024
1 parent 6142f0a commit 8a05fa2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ShellPkg/Application/Shell/ShellParametersProtocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ UpdateArgcArgv (
*OldArgc = ShellParameters->Argc;
}

if (OldArgc != NULL) {
if (OldArgv != NULL) {
*OldArgv = ShellParameters->Argv;
}

Expand Down

0 comments on commit 8a05fa2

Please sign in to comment.