Skip to content

Commit c7dcab7

Browse files
committed
Block: Add missing range checks
1 parent c5bfcde commit c7dcab7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/scratch/block.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ int Block::addInput(std::shared_ptr<Input> input)
138138
/*! Returns the input at index. */
139139
std::shared_ptr<Input> Block::inputAt(int index) const
140140
{
141+
if (index < 0 || index >= impl->inputs.size())
142+
return nullptr;
143+
141144
return impl->inputs[index];
142145
}
143146

@@ -190,6 +193,9 @@ int Block::addField(std::shared_ptr<Field> field)
190193
/*! Returns the field at index. */
191194
std::shared_ptr<Field> Block::fieldAt(int index) const
192195
{
196+
if (index < 0 || index >= impl->fields.size())
197+
return nullptr;
198+
193199
return impl->fields[index];
194200
}
195201

0 commit comments

Comments
 (0)