summaryrefslogtreecommitdiffstatshomepage
path: root/py/binary.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/binary.c')
-rw-r--r--py/binary.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/py/binary.c b/py/binary.c
index 34feb384ea..870a0942ba 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -303,7 +303,10 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
// zero/sign extend if needed
if (BYTES_PER_WORD < 8 && size > sizeof(val)) {
int c = (is_signed(val_type) && (mp_int_t)val < 0) ? 0xff : 0x00;
- memset(p + sizeof(val), c, size - sizeof(val));
+ memset(p, c, size);
+ if (struct_type == '>') {
+ p += size - sizeof(val);
+ }
}
}
}
@@ -368,6 +371,7 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
case 'q':
((long long*)p)[index] = val;
+ break;
case 'Q':
((unsigned long long*)p)[index] = val;
break;
@@ -383,5 +387,6 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m
// Extension to CPython: array of pointers
case 'P':
((void**)p)[index] = (void*)(uintptr_t)val;
+ break;
}
}