Skip to content

Commit 7d4bf3c

Browse files
committed
free errmsg & prevent leaks
1 parent ff23184 commit 7d4bf3c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ext/pdo_oci/oci_driver.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, swor
6363

6464
einfo = &H->einfo;
6565

66+
if (einfo->errmsg) {
67+
pefree(einfo->errmsg, dbh->is_persistent);
68+
einfo->errmsg = NULL;
69+
}
70+
6671
if (stmt) {
6772
S = (pdo_oci_stmt*)stmt->driver_data;
6873
einfo = &S->einfo;
@@ -184,7 +189,12 @@ static int oci_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
184189
OCIHandleFree(H->env, OCI_HTYPE_ENV);
185190
H->env = NULL;
186191
}
187-
192+
193+
if (H->einfo.errmsg) {
194+
pefree(H->einfo.errmsg, dbh->is_persistent);
195+
H->einfo.errmsg = NULL;
196+
}
197+
188198
pefree(H, dbh->is_persistent);
189199

190200
return 0;

ext/pdo_oci/oci_statement.c

+5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ static int oci_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
8181
stmt->bound_params = NULL;
8282
}
8383

84+
if (S->einfo.errmsg) {
85+
efree(S->einfo.errmsg);
86+
S->einfo.errmsg = NULL;
87+
}
88+
8489
if (S->cols) {
8590
for (i = 0; i < stmt->column_count; i++) {
8691
if (S->cols[i].data) {

0 commit comments

Comments
 (0)