mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
MFH: Fixed bug #34884 (Possible crash in ext/sqlite when sqlite.assoc_case
is being used).
This commit is contained in:
parent
cc50a96139
commit
b0f1719ee5
2 changed files with 14 additions and 12 deletions
|
@ -1440,14 +1440,13 @@ next_row:
|
|||
/* first row - lets copy the column names */
|
||||
rres->col_names = safe_emalloc(rres->ncolumns, sizeof(char *), 0);
|
||||
for (i = 0; i < rres->ncolumns; i++) {
|
||||
colname = (char*)colnames[i];
|
||||
rres->col_names[i] = estrdup((char*)colnames[i]);
|
||||
|
||||
if (SQLITE_G(assoc_case) == 1) {
|
||||
php_sqlite_strtoupper(colname);
|
||||
php_sqlite_strtoupper(rres->col_names[i]);
|
||||
} else if (SQLITE_G(assoc_case) == 2) {
|
||||
php_sqlite_strtolower(colname);
|
||||
php_sqlite_strtolower(rres->col_names[i]);
|
||||
}
|
||||
rres->col_names[i] = estrdup(colname);
|
||||
}
|
||||
if (!rres->buffered) {
|
||||
/* non buffered mode - also fetch memory for on single row */
|
||||
|
@ -1686,16 +1685,17 @@ PHP_FUNCTION(sqlite_fetch_column_types)
|
|||
array_init(return_value);
|
||||
|
||||
for (i = 0; i < ncols; i++) {
|
||||
char *colname = (char *)colnames[i];
|
||||
|
||||
if (SQLITE_G(assoc_case) == 1) {
|
||||
php_sqlite_strtoupper(colname);
|
||||
} else if (SQLITE_G(assoc_case) == 2) {
|
||||
php_sqlite_strtolower(colname);
|
||||
}
|
||||
|
||||
if (result_type == PHPSQLITE_ASSOC) {
|
||||
char *colname = estrdup((char *)colnames[i]);
|
||||
|
||||
if (SQLITE_G(assoc_case) == 1) {
|
||||
php_sqlite_strtoupper(colname);
|
||||
} else if (SQLITE_G(assoc_case) == 2) {
|
||||
php_sqlite_strtolower(colname);
|
||||
}
|
||||
|
||||
add_assoc_string(return_value, colname, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
|
||||
efree(colname);
|
||||
}
|
||||
if (result_type == PHPSQLITE_NUM) {
|
||||
add_index_string(return_value, i, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue