Skip to content

[BUG] parse_args with empty vector crashes #408

@Tomdein

Description

@Tomdein

I wanted to use this lib to parse args in cutom 'interactive console', so I used std::cin to read the input and split it into the std::vectorstd::string and run it in a loop.

But if you input empty line (just press enter) -> empty vector -> argparse crashes in parse_args_internal because the iterators are invalid with empty vector.


You maybe want to do some sanity check for the input.


I solved it in my code by just inserting the name of the command in front of the vector:
args.insert(args.begin(), "<program_name>");


Is this an edge case? Yes
Did I spend way too much time on this because in my case I do not have access to debugger? Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions