]> granicus.if.org Git - php/commitdiff
Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO).
authorIlia Alshanetsky <iliaa@php.net>
Wed, 14 Mar 2012 20:20:33 +0000 (20:20 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 14 Mar 2012 20:20:33 +0000 (20:20 +0000)
NEWS
ext/pdo_odbc/odbc_stmt.c

diff --git a/NEWS b/NEWS
index 873ed048734df8c59d503af5d4c006b3c128cda5..c682466b5cdfd2befc7f7101982061b265665345 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -75,6 +75,9 @@ PHP                                                                        NEWS
   . Fixed bug #61194 (PDO should export compression flag with myslqnd).
     (Johannes)
 
+- PDO_odbc
+  . Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO). (Ilia)
+
 - Phar
   . Fixed bug #61184 (Phar::webPhar() generates headers with trailing NUL
     bytes). (Nikita Popov)
index aabe3dcc369aa2460e5278444d5516bab76b99dd..4e039d2a740b6477a9d6e2b6a498bc27fdda0b62 100755 (executable)
@@ -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;