Skip to content

Commit

Permalink
Add assertion that 'pos' is in-bounds (#3466)
Browse files Browse the repository at this point in the history
  • Loading branch information
colesbury authored Nov 3, 2017
1 parent a8efd88 commit 42de0df
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions torch/csrc/autograd/input_buffer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "torch/csrc/autograd/input_buffer.h"

#include "torch/csrc/assertions.h"
#include "torch/csrc/autograd/functions/basic_ops.h"
#include "torch/csrc/utils/auto_gpu.h"

Expand All @@ -10,6 +11,7 @@ InputBuffer::InputBuffer(size_t size)
{}

void InputBuffer::add(size_t pos, Variable var) {
TORCH_ASSERT(pos >= 0 && pos < buffer.size());
if (!var.defined()) {
return;
}
Expand Down

0 comments on commit 42de0df

Please sign in to comment.