mirror of
https://github.com/libretro/glslang.git
synced 2024-12-11 18:03:32 +00:00
Merge pull request #17 from google/non-existing-string
Protect location setting methods from writing to non-existing strings.
This commit is contained in:
commit
a417f01041
@ -123,10 +123,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for #line override
|
// for #line override
|
||||||
void setLine(int newLine) { loc[currentSource].line = newLine; }
|
void setLine(int newLine) { loc[getLastValidSourceIndex()].line = newLine; }
|
||||||
void setString(int newString) { loc[currentSource].string = newString; }
|
void setString(int newString) { loc[getLastValidSourceIndex()].string = newString; }
|
||||||
|
|
||||||
const TSourceLoc& getSourceLoc() const { return loc[std::max(0, std::min(currentSource, numSources - finale - 1))]; }
|
const TSourceLoc& getSourceLoc() const { return loc[std::max(0, std::min(currentSource, numSources - finale - 1))]; }
|
||||||
|
// Returns the index (starting from 0) of the most recent valid source string we are reading from.
|
||||||
|
int getLastValidSourceIndex() const { return std::min(currentSource, numSources - 1); }
|
||||||
|
|
||||||
void consumeWhiteSpace(bool& foundNonSpaceTab);
|
void consumeWhiteSpace(bool& foundNonSpaceTab);
|
||||||
bool consumeComment();
|
bool consumeComment();
|
||||||
|
Loading…
Reference in New Issue
Block a user