Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[MXNET-953] Fix oob memory read (v1.3.x) #13118

Merged
merged 1 commit into from
Nov 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/operator/tensor/elemwise_unary_op_basic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ void ShapeComputeCPU(const nnvm::NodeAttrs& attrs,
CHECK_EQ(req.size(), 1U);
const TBlob& in_data = inputs[0];
const TBlob& out_data = outputs[0];
memcpy(out_data.dptr_, in_data.shape_.data(), in_data.ndim() * sizeof(int64_t));
size_t type_size = mshadow::mshadow_sizeof(out_data.type_flag_);
memcpy(out_data.dptr_, in_data.shape_.data(), in_data.ndim() * type_size);
}

NNVM_REGISTER_OP(shape_array)
Expand Down Expand Up @@ -540,8 +541,9 @@ void SizeComputeCPU(const nnvm::NodeAttrs& attrs,
CHECK_EQ(req.size(), 1U);
const TBlob& in_data = inputs[0];
const TBlob& out_data = outputs[0];
size_t type_size = mshadow::mshadow_sizeof(out_data.type_flag_);
const index_t size_var = in_data.Size();
memcpy(out_data.dptr_, &size_var, 1U * sizeof(int64_t));
memcpy(out_data.dptr_, &size_var, type_size);
}

NNVM_REGISTER_OP(size_array)
Expand Down