Skip to content

Commit

Permalink
Fix nullptr addition (#65548)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #65548

Fixes
caffe2/test:jit - test_unsupported_nn_functional_pad_circular_cpu_float32 (test_jit_fuser_te.TestNNCOpInfoCPU)

Test Plan: Sandcastle

Reviewed By: ngimel

Differential Revision: D31148405

fbshipit-source-id: 4c8c693a45229ab4e59b0b0ec5326d3ac114dbaf
  • Loading branch information
r-barnes authored and facebook-github-bot committed Sep 24, 2021
1 parent c3b09e9 commit 760aefd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions c10/core/TensorImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,13 @@ struct C10_API TensorImpl : public c10::intrusive_ptr_target {
dtype_initialized(),
"Cannot access data pointer of Tensor that doesn't have initialized dtype "
"(e.g., caffe2::Tensor x(CPU), prior to calling mutable_data<T>() on x)");
return static_cast<void*>(
static_cast<char*>(storage_.data()) +
data_type_.itemsize() * storage_offset_);
if (storage_offset_) {
return static_cast<void*>(
static_cast<char*>(storage_.data()) +
data_type_.itemsize() * storage_offset_);
} else {
return storage_.data();
}
}

/**
Expand Down

0 comments on commit 760aefd

Please sign in to comment.