/* 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 */
array_init(return_value);
for (i = 0; i < ncols; i++) {
- char *colname = (char *)colnames[i];
+ char *colname = estrdup((char *)colnames[i]);
if (SQLITE_G(assoc_case) == 1) {
php_sqlite_strtoupper(colname);
add_index_string(return_value, i, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
}
}
+ efree(colname);
}
done: