diff options
| author | Anders Leino <aleino@nvidia.com> | 2025-02-28 03:58:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-27 17:58:07 -0800 |
| commit | 4d415f6af2266cc38798d72f6816c60b91a5003c (patch) | |
| tree | c5d0e373b9980aeb10d7f3e3c022fd3edf615f98 /source/slang/slang.cpp | |
| parent | 96f19629d4cfbe282af010cee704409a6fb2f59c (diff) | |
Fix a bug where Session::parseCommandLineArguments returns invalid data (#6461)
This helps to address issue #4760.
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 001354162..cd8cabfe5 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -1108,17 +1108,19 @@ SLANG_NO_THROW SlangResult SLANG_MCALL Session::parseCommandLineArguments( if (outDesc->structureSize < sizeof(slang::SessionDesc)) return SLANG_E_BUFFER_TOO_SMALL; RefPtr<ParsedCommandLineData> outData = new ParsedCommandLineData(); - SerializedOptionsData optionData; RefPtr<EndToEndCompileRequest> tempReq = new EndToEndCompileRequest(this); tempReq->processCommandLineArguments(argv, argc); + outData->options.setCount(1 + tempReq->getLinkage()->targets.getCount()); + int optionDataIndex = 0; + SerializedOptionsData& optionData = outData->options[optionDataIndex]; + optionDataIndex++; tempReq->getOptionSet().serialize(&optionData); - outData->options.add(optionData); for (auto target : tempReq->getLinkage()->targets) { slang::TargetDesc tdesc; - SerializedOptionsData targetOptionData; + SerializedOptionsData& targetOptionData = outData->options[optionDataIndex]; + optionDataIndex++; tempReq->getTargetOptionSet(target).serialize(&targetOptionData); - outData->options.add(targetOptionData); tdesc.compilerOptionEntryCount = (uint32_t)targetOptionData.entries.getCount(); tdesc.compilerOptionEntries = targetOptionData.entries.getBuffer(); outData->targets.add(tdesc); |
