Skip to content

Commit 682c27a

Browse files
authored
Fix husk -o/-j argument bounds check (#2658)
The guard "i < commandLine.size() - 2" was off by one and dropped the valid trailing pair (e.g. {"-o", "out.exr"} of size 2). It also underflows when commandLine.size() < 2, since size() is unsigned. Rewrote as "i + 1 < commandLine.size()" so the next-element access is bounded correctly without unsigned underflow.
1 parent dd9d814 commit 682c27a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

libs/render_delegate/render_delegate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -879,13 +879,13 @@ void HdArnoldRenderDelegate::_SetRenderSetting(const TfToken& _key, const VtValu
879879
const VtStringArray &commandLine = value.UncheckedGet<VtArray<std::string>>();
880880
for (unsigned int i = 0; i < commandLine.size(); ++i) {
881881
// husk argument for output image
882-
if (commandLine[i] == "-o" && i < commandLine.size() - 2) {
882+
if (commandLine[i] == "-o" && i + 1 < commandLine.size()) {
883883
_outputOverride = commandLine[++i];
884884
continue;
885885
}
886886
// husk argument for thread count (#1077)
887-
if ((commandLine[i] == "-j" || commandLine[i] == "--threads")
888-
&& i < commandLine.size() - 2) {
887+
if ((commandLine[i] == "-j" || commandLine[i] == "--threads")
888+
&& i + 1 < commandLine.size()) {
889889
// if for some reason the argument value is not a number, atoi should return 0
890890
// which is also the default arnold value.
891891
AiNodeSetInt(_options, str::threads, std::atoi(commandLine[++i].c_str()));

0 commit comments

Comments
 (0)