summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2012-03-14 20:20:33 +0000
committerIlia Alshanetsky <iliaa@php.net>2012-03-14 20:20:33 +0000
commit601d17d1ae2fb3ac6c232e9d66cb541c266c93b4 (patch)
treeae5e475f064f16431933deb55c22f49d91e48119 /ext
parent8665e02ccd79cd5addfdaa3b0338a7432893c8b5 (diff)
downloadphp-git-601d17d1ae2fb3ac6c232e9d66cb541c266c93b4.tar.gz
Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO).
Diffstat (limited to 'ext')
-rwxr-xr-xext/pdo_odbc/odbc_stmt.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c
index aabe3dcc36..4e039d2a74 100755
--- a/ext/pdo_odbc/odbc_stmt.c
+++ b/ext/pdo_odbc/odbc_stmt.c
@@ -637,12 +637,14 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l
if (C->fetched_len != SQL_NO_TOTAL) {
/* use size suggested by the driver, if it knows it */
- alloced = C->fetched_len + 1;
+ buf = emalloc(C->fetched_len + 1);
+ memcpy(buf, C->data, C->fetched_len);
+ buf[C->fetched_len] = 0;
+ used = C->fetched_len;
+ } else {
+ buf = estrndup(C->data, 256);
+ used = 255; /* not 256; the driver NUL terminated the buffer */
}
-
- buf = emalloc(alloced);
- memcpy(buf, C->data, 256);
- used = 255; /* not 256; the driver NUL terminated the buffer */
do {
C->fetched_len = 0;