Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 16443 - Segmentation fault when option name is empty #4753

Merged
merged 1 commit into from
Aug 28, 2016

Conversation

jdeschenes
Copy link
Contributor

Prevent a segmentation fault when the option name is empty.

I am not convinced the type of Exception is correct since this is not a user error, but a programming error.

Comments are appreciated.

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
16443 std.getopt: segmentation fault with empty string option

@dlang-bot
Copy link
Contributor

@jdeschenes, thanks for your PR! By analyzing the annotation information on this pull request, we identified @andralex, @burner and @AndrejMitrovic to be potential reviewers. @andralex: The PR was automatically assigned to you, please reassign it if you were identified mistakenly.

(The DLang Bot is under development. If you experience any issues, please open an issue at its repo.)

@@ -671,6 +673,11 @@ private void getoptImpl(T...)(ref string[] args, ref configuration cfg,
{
// it's an option string
auto option = to!string(opts[0]);
if (option.length == 0)
{
excep = new GetOptException("An option may not be an empty string", excep);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 spaces after indentation please (there's 2).

@AndrejMitrovic
Copy link
Contributor

LGTM except the indentation.

If the option name is an empty string an Exception will be raised instead.
@burner
Copy link
Member

burner commented Aug 28, 2016

Auto-merge toggled on

@burner burner merged commit 82ff5bc into dlang:master Aug 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants