diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2019-03-12 16:44:45 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2019-03-12 16:44:45 +0800 |
commit | 497fa07d29b247b89310c5369c8fe3490246806a (patch) | |
tree | b77e1226d4141208abd670d6fd9230245f5347ce | |
parent | bc141e2d30c211758d2c92b55bf25424ea56bbdc (diff) | |
download | tangerine-mcl-497fa07d29b247b89310c5369c8fe3490246806a.tar.gz tangerine-mcl-497fa07d29b247b89310c5369c8fe3490246806a.tar.zst tangerine-mcl-497fa07d29b247b89310c5369c8fe3490246806a.zip |
fix Vint::setArray(x) for x == self
-rw-r--r-- | include/mcl/vint.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/mcl/vint.hpp b/include/mcl/vint.hpp index 83dd34d..6ace405 100644 --- a/include/mcl/vint.hpp +++ b/include/mcl/vint.hpp @@ -1176,8 +1176,15 @@ public: size_t unitSize = (sizeof(S) * size + sizeof(Unit) - 1) / sizeof(Unit); buf_.alloc(pb, unitSize); if (!*pb) return; - buf_[unitSize - 1] = 0; - memcpy(&buf_[0], x, sizeof(S) * size); + char *dst = (char *)&buf_[0]; + const char *src = (const char *)x; + size_t i = 0; + for (; i < sizeof(S) * size; i++) { + dst[i] = src[i]; + } + for (; i < sizeof(Unit) * unitSize; i++) { + dst[i] = 0; + } trim(unitSize); } /* |