diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-02-26 19:40:14 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-02-26 19:40:14 +0100 |
| commit | 855f0f3e778de66ba3943ca3ba79606f58b8b887 (patch) | |
| tree | 1bb3c15c29441db4b0c9a91f593b626c4e849b3c /src/iso19111/io.cpp | |
| parent | 1205f97351f7e5a5ff645e01c6418a42bef3022d (diff) | |
| download | PROJ-855f0f3e778de66ba3943ca3ba79606f58b8b887.tar.gz PROJ-855f0f3e778de66ba3943ca3ba79606f58b8b887.zip | |
io.cpp: cast to 'unsigned char' before isspace() to avoid undefined behaviour, for example on netBSD 8
Diffstat (limited to 'src/iso19111/io.cpp')
| -rw-r--r-- | src/iso19111/io.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index a1608464..d17d6329 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -973,7 +973,7 @@ const std::vector<WKTNodeNNPtr> &WKTNode::children() const { //! @cond Doxygen_Suppress static size_t skipSpace(const std::string &str, size_t start) { size_t i = start; - while (i < str.size() && ::isspace(str[i])) { + while (i < str.size() && ::isspace(static_cast<unsigned char>(str[i]))) { ++i; } return i; @@ -1002,8 +1002,9 @@ WKTNodeNNPtr WKTNode::createFrom(const std::string &wkt, size_t indexStart, bool inString = false; for (; i < wkt.size() && - (inString || (wkt[i] != '[' && wkt[i] != '(' && wkt[i] != ',' && - wkt[i] != ']' && wkt[i] != ')' && !::isspace(wkt[i]))); + (inString || + (wkt[i] != '[' && wkt[i] != '(' && wkt[i] != ',' && wkt[i] != ']' && + wkt[i] != ')' && !::isspace(static_cast<unsigned char>(wkt[i])))); ++i) { if (wkt[i] == '"') { if (!inString) { @@ -5317,7 +5318,7 @@ PROJStringSyntaxParser(const std::string &projString, std::vector<Step> &steps, { size_t i = 0; while (true) { - for (; isspace(c_str[i]); i++) { + for (; isspace(static_cast<unsigned char>(c_str[i])); i++) { } std::string token; bool in_string = false; @@ -5334,7 +5335,7 @@ PROJStringSyntaxParser(const std::string &projString, std::vector<Step> &steps, token += c_str[i]; i++; continue; - } else if (isspace(c_str[i])) { + } else if (isspace(static_cast<unsigned char>(c_str[i]))) { break; } token += c_str[i]; |
