summaryrefslogtreecommitdiff
path: root/ext/pdo_dblib/dblib_stmt.c
diff options
context:
space:
mode:
authorSteph Fox <sfox@php.net>2009-03-19 22:16:29 (GMT)
committerSteph Fox <sfox@php.net>2009-03-19 22:16:29 (GMT)
commitf5a65cabfde854100143fb5c01480f797c263264 (patch)
tree27f1e89f2e8fe2bbb10c4e2b65b5e292f3af91cd /ext/pdo_dblib/dblib_stmt.c
parent91d325dd729391b74d1cf5410778a27bbba84041 (diff)
downloadphp-f5a65cabfde854100143fb5c01480f797c263264.tar.gz
MFH
- Fix bug #38805 ( PDO Truncates Text from SQL Server Text Data Type Field) - Bring behaviour into line with ext/mssql - Several memleaks plugged
Diffstat (limited to 'ext/pdo_dblib/dblib_stmt.c')
-rw-r--r--ext/pdo_dblib/dblib_stmt.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c
index 0e7f0d4..c8bf9f7 100644
--- a/ext/pdo_dblib/dblib_stmt.c
+++ b/ext/pdo_dblib/dblib_stmt.c
@@ -113,18 +113,27 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
stmt->column_count = S->ncols;
for (i = 0, j = 0; i < S->ncols; i++) {
+ char *tmp = NULL;
+
S->cols[i].coltype = dbcoltype(H->link, i+1);
- S->cols[i].name = dbcolname(H->link, i+1);
- if (S->cols[i].name) {
- S->cols[i].name = estrdup(S->cols[i].name);
- } else if (j) {
- spprintf(&S->cols[i].name, 0, "computed%d", j++);
- } else {
- S->cols[i].name = estrdup("computed");
- j++;
+ S->cols[i].name = (char*)dbcolname(H->link, i+1);
+
+ if (!strlen(S->cols[i].name)) {
+ if (j) {
+ spprintf(&tmp, 0, "computed%d", j++);
+ strlcpy(S->cols[i].name, tmp, strlen(tmp)+1);
+ efree(tmp);
+ } else {
+ S->cols[i].name = "computed";
+ j++;
+ }
}
- S->cols[i].source = dbcolsource(H->link, i+1);
- S->cols[i].source = estrdup(S->cols[i].source ? S->cols[i].source : "");
+
+ S->cols[i].source = (char*)dbcolsource(H->link, i+1);
+ tmp = estrdup(S->cols[i].source ? S->cols[i].source : "");
+ S->cols[i].source = tmp;
+ efree(tmp);
+
S->cols[i].maxlen = dbcollen(H->link, i+1);
}
}