msphpsql icon indicating copy to clipboard operation
msphpsql copied to clipboard

SEGMENTATION FAULT when using array with keys

Open GDmac opened this issue 2 years ago • 3 comments

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));

GDmac avatar Jul 27 '23 13:07 GDmac

I can reproduce this, and will investigate further.

v-makouz avatar Jul 28 '23 07:07 v-makouz

We know where the error is, so now it's a matter of applying the fix.

v-makouz avatar Aug 04 '23 22:08 v-makouz

can the fix be back-ported to 5.10 (5.10.1 ?) too - some of our projects will remain on old PHP 😬

GDmac avatar Aug 05 '23 18:08 GDmac