py: Use memmove instead of memcpy when appropriate.

Found this bug by running unix/ tests with DEBUG=1 enabled when
compiling.
This commit is contained in:
Damien George
2014-08-29 21:07:54 +01:00
parent 02d95d7ce9
commit 17ae2395c2
3 changed files with 4 additions and 4 deletions

View File

@@ -274,7 +274,7 @@ STATIC mp_obj_t list_pop(uint n_args, const mp_obj_t *args) {
uint index = mp_get_index(self->base.type, self->len, n_args == 1 ? MP_OBJ_NEW_SMALL_INT(-1) : args[1], false);
mp_obj_t ret = self->items[index];
self->len -= 1;
memcpy(self->items + index, self->items + index + 1, (self->len - index) * sizeof(mp_obj_t));
memmove(self->items + index, self->items + index + 1, (self->len - index) * sizeof(mp_obj_t));
// Clear stale pointer from slot which just got freed to prevent GC issues
self->items[self->len] = MP_OBJ_NULL;
if (self->alloc > LIST_MIN_ALLOC && self->alloc > 2 * self->len) {