D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16443 - std.getopt: segmentation fault with empty string option
Summary: std.getopt: segmentation fault with empty string option
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-28 16:22 UTC by Jean-Mathieu Deschenes
Modified: 2016-10-01 11:47 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jean-Mathieu Deschenes 2016-08-28 16:22:00 UTC
When using the following:
-------------------------

import std.getopt;

void main(string[] args)
{
	bool error_here;

	auto information = getopt(
		args,
		"", &error_here,
		);
}


-----------------------

Will result in a segmentation fault during execution.
Comment 1 Robert Schadek 2016-08-28 18:04:52 UTC
I'll work on that.
Comment 2 Jean-Mathieu Deschenes 2016-08-28 18:34:42 UTC
Hi,

I have already created a PR for it.

Let me know what you think:

https://github.com/dlang/phobos/pull/4753
Comment 3 github-bugzilla 2016-08-28 21:16:51 UTC
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/024b751547479b1ff973b0929c2aac34343f4de1
Fix Issue 16443 - Prevent segmentation fault

If the option name is an empty string an Exception will be raised instead.

https://github.com/dlang/phobos/commit/82ff5bc8891d1ae5421286ca1d163175cf9b1ac7
Merge pull request #4753 from jdeschenes/empty_getopt

Fix Issue 16443 - Segmentation fault when option name is empty
Comment 4 github-bugzilla 2016-10-01 11:47:04 UTC
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/024b751547479b1ff973b0929c2aac34343f4de1
Fix Issue 16443 - Prevent segmentation fault

https://github.com/dlang/phobos/commit/82ff5bc8891d1ae5421286ca1d163175cf9b1ac7
Merge pull request #4753 from jdeschenes/empty_getopt