diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-24 14:24:59 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-24 14:24:59 +0100 |
commit | 6cb52deaad36f59738b6b4d203457a7f8d2d13e9 (patch) | |
tree | 000cbd20c218ebd575a175b019298bd65228fe94 /src/core/resource | |
parent | 2e8432a2fd10f4cf5519628c7ab6e7c6e270ca15 (diff) |
Fixed integer overflow bug in SourceContextReader, adapted TerminaLoggerTest
Diffstat (limited to 'src/core/resource')
-rw-r--r-- | src/core/resource/ResourceManager.cpp | 7 | ||||
-rw-r--r-- | src/core/resource/ResourceManager.hpp | 20 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/core/resource/ResourceManager.cpp b/src/core/resource/ResourceManager.cpp index 059da41..184a16d 100644 --- a/src/core/resource/ResourceManager.cpp +++ b/src/core/resource/ResourceManager.cpp @@ -22,6 +22,7 @@ #include <core/common/Exceptions.hpp> #include <core/common/Logger.hpp> #include <core/common/Rtti.hpp> +#include <core/common/SourceContextReader.hpp> #include <core/common/Utils.hpp> #include <core/model/Node.hpp> #include <core/parser/ParserContext.hpp> @@ -280,5 +281,11 @@ SourceContext ResourceManager::readContext(const SourceLocation &location, } return SourceContext{}; } + +SourceContext ResourceManager::readContext(const SourceLocation &location) +{ + return readContext(location, SourceContextReader::MAX_MAX_CONTEXT_LENGTH); +} + } diff --git a/src/core/resource/ResourceManager.hpp b/src/core/resource/ResourceManager.hpp index d5381b9..221e2cc 100644 --- a/src/core/resource/ResourceManager.hpp +++ b/src/core/resource/ResourceManager.hpp @@ -34,7 +34,6 @@ #include <core/common/Location.hpp> #include <core/common/Rtti.hpp> -#include <core/common/SourceContextReader.hpp> #include <core/managed/Managed.hpp> #include "Resource.hpp" @@ -230,9 +229,22 @@ public: * @return a valid SourceContext if a valid SourceLocation was given or an * invalid SourceContext if the location is invalid. */ - SourceContext readContext( - const SourceLocation &location, - size_t maxContextLength = SourceContextReader::MAX_MAX_CONTEXT_LENGTH); + SourceContext readContext(const SourceLocation &location, + size_t maxContextLength); + /** + * Creates and returns a SourceContext structure containing information + * about the given SourceLocation (such as line and column number). Throws + * a LoggableException if an irrecoverable error occurs while looking up the + * context (such as a no longer existing resource). Does not limit the + * context length. + * + * @param location is the SourceLocation for which context information + * should be retrieved. This method is used by the Logger class to print + * pretty messages. + * @return a valid SourceContext if a valid SourceLocation was given or an + * invalid SourceContext if the location is invalid. + */ + SourceContext readContext(const SourceLocation &location); }; } |