Skip to content

Commit d7fd614

Browse files
committed
fix leaks and add one more NULL check
1 parent a310c3b commit d7fd614

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

ext/pdo_dblib/dblib_stmt.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,33 @@ static int pdo_dblib_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC)
104104
dbcancel(H->link);
105105

106106
if (stmt->columns) {
107+
int i = 0;
108+
for (; i < stmt->column_count; i++) {
109+
if (stmt->columns[i].name) {
110+
efree(stmt->columns[i].name);
111+
}
112+
}
107113
efree(stmt->columns);
108114
stmt->columns = NULL;
109115
}
110-
116+
111117
return 1;
112118
}
113119

114120
static int pdo_dblib_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
115121
{
116122
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
117123

118-
efree(stmt->columns);
119-
stmt->columns = NULL;
124+
if (stmt->columns) {
125+
int i = 0;
126+
for (; i < stmt->column_count; i++) {
127+
if (stmt->columns[i].name) {
128+
efree(stmt->columns[i].name);
129+
}
130+
}
131+
efree(stmt->columns);
132+
stmt->columns = NULL;
133+
}
120134

121135
efree(S);
122136

0 commit comments

Comments
 (0)