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

Commit

Permalink
[MXNET-953] Fix oob memory read (#12631)
Browse files Browse the repository at this point in the history
  • Loading branch information
KellenSunderland authored and marcoabreu committed Nov 12, 2018
1 parent 3c5fa16 commit c00697c
Showing 1 changed file with 4 additions and 2 deletions.
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 @@ -492,7 +492,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 @@ -542,8 +543,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

0 comments on commit c00697c

Please sign in to comment.