Fix bug #81343: inconsistent type conversion after closeCursor

S->cols is already freed in the statement destructor and since
caa710037e the column data is only
populated on the first execute() which means that on subsequent
execute()s after closeCursor was called, all meta-data for column types
was removed and never restored

Closes GH-7355.
This commit is contained in:
Philip Hofstetter 2021-08-10 15:28:29 +02:00 committed by Nikita Popov
parent 865b096890
commit ace8fba759
3 changed files with 33 additions and 8 deletions

View file

@ -240,8 +240,8 @@ stmt_retry:
return 0;
}
if (!stmt->executed && (!stmt->column_count || S->cols == NULL)) {
stmt->column_count = (int) PQnfields(S->result);
stmt->column_count = (int) PQnfields(S->result);
if (S->cols == NULL) {
S->cols = ecalloc(stmt->column_count, sizeof(pdo_pgsql_column));
}
@ -674,12 +674,6 @@ static int pgsql_stmt_get_column_meta(pdo_stmt_t *stmt, zend_long colno, zval *r
static int pdo_pgsql_stmt_cursor_closer(pdo_stmt_t *stmt)
{
pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;
if (S->cols != NULL){
efree(S->cols);
S->cols = NULL;
}
return 1;
}