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

 ##########
 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:
   Let me add some logging code to see what types are used here.  My assumption 
is that uint64 is used for all size operations.  It's large enough to handle 
large indexes and it's integer type, which makes sense for sizes (as opposed to 
floats).  Let me do a few test runs here in CI and validate those assumptions.

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