diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2024-05-08 12:25:11 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-08 12:25:11 -0700 |
| commit | 708345d16a877ac164171439cf9b4ea825b78d23 (patch) | |
| tree | cb55913f8a45db4cdfd0aa1d5d6f8d4698f14696 | |
| parent | 6d917a02bb307300ac14c8b028c47fcdcc07100b (diff) | |
Fix crash in obfuscation (#4134)
Slang crashes during obfuscation because of referencing the nullptr
pointer. Add the checking.
In addition, above situation happens when user provide an empty slang
shader with '-obfuscate' option, we shouldn't do anything in that case.
So add an early return in obfuscateModuleLocs if no IR code is actually
generated.
| -rw-r--r-- | source/slang/slang-ir-obfuscate-loc.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source/slang/slang-ir-obfuscate-loc.cpp b/source/slang/slang-ir-obfuscate-loc.cpp index 9aef6f6a6..79497e7a3 100644 --- a/source/slang/slang-ir-obfuscate-loc.cpp +++ b/source/slang/slang-ir-obfuscate-loc.cpp @@ -68,6 +68,11 @@ SlangResult obfuscateModuleLocs(IRModule* module, SourceManager* sourceManager) // Find all of the instructions with source locs _findInstsRec(module->getModuleInst(), instWithLocs); + if (instWithLocs.getCount() == 0) + { + // Nothing to do + return SLANG_OK; + } // Sort them instWithLocs.sort(); @@ -233,8 +238,8 @@ SlangResult obfuscateModuleLocs(IRModule* module, SourceManager* sourceManager) } // We can now just set all the new locs in the instructions + if(const LocPair* curPair = locPairs.getBuffer()) { - const LocPair* curPair = locPairs.getBuffer(); LocPair pair = *curPair; for (const auto& instWithLoc : instWithLocs) |
