diff options
author | Piotr Sarna <p.sarna@tlen.pl> | 2022-11-18 20:12:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-18 19:12:36 +0000 |
commit | 19cb68dd0cfb2070b434ab9a1bd5b5b9d46fe09b (patch) | |
tree | 2f4423d7a78146f948418a1e7b7e1d06bc5b8576 /src | |
parent | 15009945aca9b81d7c57d797bbafa58dfaa4c891 (diff) | |
download | binaryen-19cb68dd0cfb2070b434ab9a1bd5b5b9d46fe09b.tar.gz binaryen-19cb68dd0cfb2070b434ab9a1bd5b5b9d46fe09b.tar.bz2 binaryen-19cb68dd0cfb2070b434ab9a1bd5b5b9d46fe09b.zip |
Avoid calling back() on an empty string in setBinaryenBinDir (#5280)
std::string::back() is only well defined for non-empty strings.
Without the change, wasm-reduce fails if it is called from
$PATH, because then, the parent directory is an empty string.
A workaround is to explicitly set the binaryen path with -b,
and it is still necessary after this fix, but at least the program
ends with a comprehensible error message instead of a generic
assertion failure from the standard library.
Diffstat (limited to 'src')
-rw-r--r-- | src/support/path.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/support/path.cpp b/src/support/path.cpp index d3f5075c2..1858fe1e9 100644 --- a/src/support/path.cpp +++ b/src/support/path.cpp @@ -81,7 +81,7 @@ std::string getBinaryenBinDir() { void setBinaryenBinDir(const std::string& dir) { binDir = dir; - if (binDir.back() != getPathSeparator()) { + if (binDir.empty() || binDir.back() != getPathSeparator()) { binDir += getPathSeparator(); } } |