mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix GH-11451: Invalid associative array containing duplicate keys
It used the "add_new" variant which assumes the key doesn't already exist. But in case of duplicate keys we have to take the last result. Closes GH-11453.
This commit is contained in:
parent
923e72615f
commit
29a96e09b2
3 changed files with 32 additions and 1 deletions
|
@ -1982,7 +1982,9 @@ PHP_METHOD(SQLite3Result, fetchArray)
|
|||
Z_ADDREF(data);
|
||||
}
|
||||
}
|
||||
zend_symtable_add_new(Z_ARR_P(return_value), result_obj->column_names[i], &data);
|
||||
/* Note: we can't use the "add_new" variant here instead of "update" because
|
||||
* when the same column name is encountered, the last result should be taken. */
|
||||
zend_symtable_update(Z_ARR_P(return_value), result_obj->column_names[i], &data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue