Check if data would overlap and also add an assert. Previous
implementations didn't have this issue, as the direct assignment was
used.
Signed-off-by: Anatol Belski <ab@php.net>
}
static zend_always_inline void spl_heap_elem_copy(spl_ptr_heap *heap, void *to, void *from) {
+ assert(to != from);
memcpy(to, from, heap->elem_size);
}
heap->flags |= SPL_HEAP_CORRUPTED;
}
- spl_heap_elem_copy(heap, spl_heap_elem(heap, i), bottom);
+ void *to = spl_heap_elem(heap, i);
+ if (to != bottom) {
+ spl_heap_elem_copy(heap, to, bottom);
+ }
return SUCCESS;
}
/* }}} */