summaryrefslogtreecommitdiff
path: root/torch
diff options
context:
space:
mode:
authorVedanuj Goswami <vedanujg@gmail.com>2018-02-17 19:52:45 -0800
committerEdward Z. Yang <ezyang@mit.edu>2018-02-17 19:52:45 -0800
commitf51e28440869700787748f7c1542214224bcc5c9 (patch)
treef0fecb2729cf409b474139f6aaa7dc37d6b4e728 /torch
parent9c207b195a63b5a1362e7f161b696ce339f5ddae (diff)
downloadpytorch-f51e28440869700787748f7c1542214224bcc5c9.tar.gz
pytorch-f51e28440869700787748f7c1542214224bcc5c9.tar.bz2
pytorch-f51e28440869700787748f7c1542214224bcc5c9.zip
Fix ASAN detected global buffer overflows in autograd (#5289)
* Fix asan buffer overflow in autograd saved_variable.cpp * Fix asan global buffer overflow in any_variable_requires_grad * Revert change in any_variable_requires_grad
Diffstat (limited to 'torch')
-rw-r--r--torch/csrc/autograd/saved_variable.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/torch/csrc/autograd/saved_variable.cpp b/torch/csrc/autograd/saved_variable.cpp
index 29d7e7ad30..889f456c8b 100644
--- a/torch/csrc/autograd/saved_variable.cpp
+++ b/torch/csrc/autograd/saved_variable.cpp
@@ -13,12 +13,12 @@
namespace torch { namespace autograd {
-SavedVariable::SavedVariable(const Variable& variable, bool is_output)
- : output_nr_(variable.output_nr()),
- requires_grad_(variable.requires_grad()),
- has_grad_fn_(!variable.is_leaf()) {
+SavedVariable::SavedVariable(const Variable& variable, bool is_output) {
if (variable.defined()) {
was_default_constructed_ = false;
+ output_nr_ = variable.output_nr();
+ requires_grad_ = variable.requires_grad();
+ has_grad_fn_ = !variable.is_leaf();
// These copies are all shared_ptr copies, so slightly more expensive.
// Do them here instead of in the init list in case data is undefined.
data_ = variable.data();