commit | b9e7ed4ebcf8c7723dbb916e67c44e75fcb857f1 | [log] [tgz] |
---|---|---|
author | Damien George <damien.p.george@gmail.com> | Sun Apr 13 12:40:50 2014 +0100 |
committer | Damien George <damien.p.george@gmail.com> | Sun Apr 13 12:40:50 2014 +0100 |
tree | c05b2f494f34df0f78ca689af642d3bf361fd6f6 | |
parent | 5213eb35b52b0673fbc934c70274d1ebd82813af [diff] [blame] |
py: Oops, fix int.from_bytes to correctly convert bytes!
diff --git a/py/objint.c b/py/objint.c index 6db1969..2eabff8 100644 --- a/py/objint.c +++ b/py/objint.c
@@ -277,8 +277,8 @@ // convert the bytes to an integer machine_uint_t value = 0; - for (uint i = 0; i < bufinfo.len; i++) { - value += ((byte*)bufinfo.buf)[i]; + for (const byte* buf = bufinfo.buf + bufinfo.len - 1; buf >= (byte*)bufinfo.buf; buf--) { + value = (value << 8) | *buf; } return mp_obj_new_int_from_uint(value);