diff options
author | Alpha <ngcoder@live.com> | 2015-11-25 23:22:11 -0500 |
---|---|---|
committer | Alpha <ngcoder@live.com> | 2015-11-25 23:22:11 -0500 |
commit | 72fd472418967f1f9d4f8c9f066cffba74e72d10 (patch) | |
tree | a06cd92fd8dd1e7060def5e77d91a45ad978267e | |
parent | 2f6aa56949c910ad5e09c78b4f09c3d9d9e74b3e (diff) | |
download | webgrind-72fd472418967f1f9d4f8c9f066cffba74e72d10.zip webgrind-72fd472418967f1f9d4f8c9f066cffba74e72d10.tar.gz webgrind-72fd472418967f1f9d4f8c9f066cffba74e72d10.tar.bz2 |
Safegaurd against error on miss-parse of compressed name, fixes #2
What situation can produce this?
-rw-r--r-- | library/Preprocessor.php | 4 | ||||
-rw-r--r-- | library/preprocessor.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/library/Preprocessor.php b/library/Preprocessor.php index 66bed9f..7b06aaf 100644 --- a/library/Preprocessor.php +++ b/library/Preprocessor.php @@ -205,8 +205,10 @@ class Webgrind_Preprocessor return $name; } $functionIndex = $matches[1]; - if (!isset($compressedNames[$isFile][$functionIndex]) || isset($matches[2])) { + if (isset($matches[2])) { $compressedNames[$isFile][$functionIndex] = trim($matches[2]); + } else if (!isset($compressedNames[$isFile][$functionIndex])) { + return $name; // should not happen - is file valid? } return $compressedNames[$isFile][$functionIndex]; } diff --git a/library/preprocessor.cpp b/library/preprocessor.cpp index 6c15cf6..31614f3 100644 --- a/library/preprocessor.cpp +++ b/library/preprocessor.cpp @@ -288,7 +288,10 @@ private: name.erase(0, idx + 2); compressedNames[isFile][functionIndex] = name; } else { - name = compressedNames[isFile][functionIndex]; + std::map<int, std::string>::iterator nmIt = compressedNames[isFile].find(functionIndex); + if (nmIt != compressedNames[isFile].end()) { + name = nmIt->second; // should always exist for valid files + } } } |