marcoabreu closed pull request #12631: [MXNET-953] Fix oob memory read URL: https://github.com/apache/incubator-mxnet/pull/12631
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/src/operator/tensor/elemwise_unary_op_basic.cc b/src/operator/tensor/elemwise_unary_op_basic.cc index c3e9c2dc91d..dd0ad2b387d 100644 --- a/src/operator/tensor/elemwise_unary_op_basic.cc +++ b/src/operator/tensor/elemwise_unary_op_basic.cc @@ -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) @@ -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) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
