Fix potential segfault when formatting error msg (#2160)

This commit is contained in:
kinke 2017-06-10 14:53:50 +02:00 committed by GitHub
parent 2f48a468ca
commit b82d87d6ee

View file

@ -224,7 +224,13 @@ void initFromPathString(const char *&dest, const cl::opt<std::string> &src) {
dest = nullptr;
if (src.getNumOccurrences() != 0) {
if (src.empty()) {
error(Loc(), "Expected argument to '-%s'", src.ArgStr);
error(Loc(), "Expected argument to '-%s'",
#if LDC_LLVM_VER >= 308
src.ArgStr.str().c_str()
#else
src.ArgStr
#endif
);
}
dest = dupPathString(src);
}