diff options
-rw-r--r-- | llvm_mode/compare-transform-pass.so.cc | 9 | ||||
-rw-r--r-- | llvm_mode/split-switches-pass.so.cc | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/llvm_mode/compare-transform-pass.so.cc b/llvm_mode/compare-transform-pass.so.cc index 54d33e18..c89655ea 100644 --- a/llvm_mode/compare-transform-pass.so.cc +++ b/llvm_mode/compare-transform-pass.so.cc @@ -144,7 +144,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const if (!isStrcmp && !isMemcmp && !isStrncmp && !isStrcasecmp && !isStrncasecmp) continue; - /* is a str{n,}{case,}cmp/memcmp, check is we have + /* is a str{n,}{case,}cmp/memcmp, check if we have * str{case,}cmp(x, "const") or str{case,}cmp("const", x) * strn{case,}cmp(x, "const", ..) or strn{case,}cmp("const", x, ..) * memcmp(x, "const", ..) or memcmp("const", x, ..) */ @@ -211,6 +211,13 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const VarStr = Str1P; constLen = isMemcmp ? sizedLen : GetStringLength(Str2P); } + + /* bugfix thanks to pbst */ + /* ignore terminating '\0' in string for strcmp */ + if (!isSizedcmp && constLen > 0) { + constLen--; + } + if (isSizedcmp && constLen > sizedLen) { constLen = sizedLen; } diff --git a/llvm_mode/split-switches-pass.so.cc b/llvm_mode/split-switches-pass.so.cc index 17cb62c2..45847f88 100644 --- a/llvm_mode/split-switches-pass.so.cc +++ b/llvm_mode/split-switches-pass.so.cc @@ -259,7 +259,9 @@ bool SplitSwitchesTransform::splitSwitches(Module &M) { #else Cases.push_back(CaseExpr(i->getCaseValue(), i->getCaseSuccessor())); #endif - std::vector<bool> bytesChecked(Cases[0].Val->getBitWidth() / 8, false); + /* bugfix thanks to pbst + * round up bytesChecked (in case getBitWidth() % 8 != 0) */ + std::vector<bool> bytesChecked((7 + Cases[0].Val->getBitWidth()) / 8, false); BasicBlock* SwitchBlock = switchConvert(Cases, bytesChecked, OrigBlock, NewDefault, Val, 0); /* Branch to our shiny new if-then stuff... */ |