Closed henrique-borba closed 2 months ago
Fixed an issue where initializing empty ndarrays caused segmentation errors:
$a = nd::array([]);
Results:
Segmentation fault (core dumped)
This also prepares the methods print_r (__toString) and toArray to use empty arrays. With this MR the code below will succefully execute:
print_r
$a = nd::array([]); $a->dump(); print_r($a); echo $a; print_r($a->toArray());
The __toString method was incorrectly freeing memory and causing segmentation fault when trying to read an array using echo.
PHP_METHOD(NDArray, __toString) { ... char *result = NDArray_Print(ndarray, 1); RETVAL_STRING(result); efree(result); << caused segfault }
Fixed an issue where initializing empty ndarrays caused segmentation errors:
Results:
This also prepares the methods
print_r
(__toString) and toArray to use empty arrays. With this MR the code below will succefully execute:__toString segmentation fault
The __toString method was incorrectly freeing memory and causing segmentation fault when trying to read an array using echo.