Undefined behavior with memset of std::string to 0 (#18703)
authorEli Amesefe <eliamesefe@fb.com>
Tue, 2 Apr 2019 17:07:22 +0000 (10:07 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 2 Apr 2019 17:10:11 +0000 (10:10 -0700)
commit385a755b68717150591ae88f33b4232bdb4076de
tree45bcde38410a9c98877203bda06a013d2a875d4e
parenta799751e33809459584e476ade99a110f4b5500c
Undefined behavior with memset of std::string to 0 (#18703)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18703

 `zeroPtr` is sometimes a `std::string` tensor, so `memset` to 0 is undefined behavior.

This might be accidentally safe with `std::string` implementation that use SSO (Small String Optimization), but will crash otherwise.

Reviewed By: zheng-xq

Differential Revision: D14714458

fbshipit-source-id: 012a18464e6514d38ff791509b88ddc3fc55b2b1
caffe2/operators/sequence_ops.cc