Skip to content

Commit a1a3361

Browse files
committed
Merge branch 'PHP-7.2'
* PHP-7.2: Fix heap use after free
2 parents 08755e6 + c469213 commit a1a3361

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ext/pdo_pgsql/pgsql_statement.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,13 @@ static zend_always_inline char * pdo_pgsql_translate_oid_to_table(Oid oid, PGcon
618618
}
619619
efree(querystr);
620620

621-
if ((table_name = PQgetvalue(tmp_res, 0, 0)) == NULL) {
621+
if (1 == PQgetisnull(tmp_res, 0, 0) || (table_name = PQgetvalue(tmp_res, 0, 0)) == NULL) {
622622
PQclear(tmp_res);
623623
return 0;
624624
}
625625

626+
table_name = estrdup(table_name);
627+
626628
PQclear(tmp_res);
627629
return table_name;
628630
}
@@ -652,6 +654,7 @@ static int pgsql_stmt_get_column_meta(pdo_stmt_t *stmt, zend_long colno, zval *r
652654
table_name = pdo_pgsql_translate_oid_to_table(table_oid, S->H->server);
653655
if (table_name) {
654656
add_assoc_string(return_value, "table", table_name);
657+
efree(table_name);
655658
}
656659

657660
switch (S->cols[colno].pgsql_type) {

0 commit comments

Comments
 (0)