Browse Source

Fix potential uint overflow in toBigEndian

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
7a5b93db43
  1. 4
      libdevcore/CommonData.h

4
libdevcore/CommonData.h

@ -104,10 +104,10 @@ bytes asNibbles(bytesConstRef const& _s);
template <class _T, class _Out>
inline void toBigEndian(_T _val, _Out& o_out)
{
for (auto i = o_out.size(); i-- != 0; _val >>= 8)
for (auto i = o_out.size(); i != 0; _val >>= 8, i--)
{
_T v = _val & (_T)0xff;
o_out[i] = (typename _Out::value_type)(uint8_t)v;
o_out[i - 1] = (typename _Out::value_type)(uint8_t)v;
}
}

Loading…
Cancel
Save