mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Fix uninitialized memory access dependent on argc
It seems that `parse_cmd_opts` does not correctly handle no arguments, and so argc was being decremented to -1 causing uninitialized memory access when argv[0] was dereferenced at a later point.
This commit is contained in:
parent
98eceba124
commit
639faf1c7f
1 changed files with 4 additions and 2 deletions
|
@ -405,8 +405,10 @@ int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||||
int optind;
|
int optind;
|
||||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||||
if (retval != STATUS_CMD_OK) return retval;
|
if (retval != STATUS_CMD_OK) return retval;
|
||||||
argc -= optind;
|
if (!opts.stdout) {
|
||||||
argv += optind;
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
}
|
||||||
|
|
||||||
if (opts.print_help) {
|
if (opts.print_help) {
|
||||||
builtin_print_help(parser, streams, cmd, streams.out);
|
builtin_print_help(parser, streams, cmd, streams.out);
|
||||||
|
|
Loading…
Reference in a new issue