apeforest commented on a change in pull request #12631: [MXNET-953] Fix oob 
memory read
URL: https://github.com/apache/incubator-mxnet/pull/12631#discussion_r220268094
 
 

 ##########
 File path: src/operator/tensor/elemwise_unary_op_basic.cc
 ##########
 @@ -542,8 +542,7 @@ void SizeComputeCPU(const nnvm::NodeAttrs& attrs,
   CHECK_EQ(req.size(), 1U);
   const TBlob& in_data = inputs[0];
   const TBlob& out_data = outputs[0];
-  const index_t size_var = in_data.Size();
-  memcpy(out_data.dptr_, &size_var, 1U * sizeof(int64_t));
+  *static_cast<int64_t*>(out_data.dptr_) = in_data.Size();
 
 Review comment:
   Hmm...why casting to int64_t in the first place? I think maybe the fix 
should be just `sizeof(index_t)` instead of `sizeof(int64_t)`? Thanks.

----------------------------------------------------------------
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

Reply via email to