Index: src/IceGlobalContext.cpp |
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp |
index 7a21b401f36f2c5098bddecd0aa102504842a248..e4b2d892b76df07d687fb610f362e0c4797c0468 100644 |
--- a/src/IceGlobalContext.cpp |
+++ b/src/IceGlobalContext.cpp |
@@ -129,7 +129,9 @@ IceString GlobalContext::mangleName(const IceString &Name) const { |
return NewName; |
} |
- ItemsParsed = sscanf(Name.c_str(), "_Z%u%s", &BaseLength, NameBase); |
+ // Artificially limit BaseLength to 9 digits (less than 1 billion) |
+ // because sscanf behavior is undefined on integer overflow. |
JF
2014/05/25 22:50:50
Add an assert that has this comment.
Jim Stichnoth
2014/05/29 01:39:46
An assert isn't appropriate here. The idea is to
|
+ ItemsParsed = sscanf(Name.c_str(), "_Z%9u%s", &BaseLength, NameBase); |
if (ItemsParsed == 2 && BaseLength <= strlen(NameBase)) { |
// Transform _Z3barxyz ==> _ZN6Prefix3barExyz |
// ^^^^^^^^ ^ |