msphpsql
msphpsql copied to clipboard
SEGMENTATION FAULT when using array with keys
Possible fix: This should throw an Exception not a hard crash on SEGMENTATION FAULT
When parameter is an array with string keys, the driver crashes hard with a segmentation fault. php 7.4 driver 5.10 but this seems NOT fixed in later recent drivers (not tested).
$params = [ 442502 ];
// bool true
$params = [ array(442502) ];
// bool true
$params = [ array('id' => 442502) ];
// SQLerror: Parameter array 1 must have at least one value or variable
$params = [ array('id' => 442502, 'foo' => 'bar') ];
// SEGMENTATION FAULT: 11 !!!!!
$res = sqlsrv_query($conn, "SELECT id FROM product WHERE id = ?", $params);
if (sqlsrv_errors()) var_dump(sqlsrv_errors());
var_dump(sqlsrv_has_rows($res));
I can reproduce this, and will investigate further.
We know where the error is, so now it's a matter of applying the fix.
can the fix be back-ported to 5.10 (5.10.1 ?) too - some of our projects will remain on old PHP 😬