php-ds / ext-ds

An extension providing efficient data structures for PHP 7
https://medium.com/p/9dda7af674cd
MIT License
2.11k stars 95 forks source link

Queue segfaults when iterating a copy #143

Closed robincafolla closed 5 years ago

robincafolla commented 5 years ago
PHP version: PHP 7.2.16-1+ubuntu16.04.1+deb.sury.org+1

Iterating directly on a copied queue seg faults:

use Ds\Queue;

$queue = new Queue();
$queue->push(1, 2, 3);

foreach ($queue->copy() as $value) {
  // Segfaults
}

The work around is to store the copy in a new variable:

use Ds\Queue;

$queue = new Queue();
$queue->push(1, 2, 3);
$copy = $queue->copy();

foreach ($copy as $value) {
  // No Segfaults
}
rtheunissen commented 5 years ago

This has now been fixed and release as part of 1.2.9 :sparkles: