Skip to content

Commit 0af900f

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO).
1 parent 0fde9ac commit 0af900f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ PHP NEWS
7575
. Fixed bug #61194 (PDO should export compression flag with myslqnd).
7676
(Johannes)
7777

78+
- PDO_odbc
79+
. Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO). (Ilia)
80+
7881
- Phar
7982
. Fixed bug #61184 (Phar::webPhar() generates headers with trailing NUL
8083
bytes). (Nikita Popov)

ext/pdo_odbc/odbc_stmt.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,14 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l
637637

638638
if (C->fetched_len != SQL_NO_TOTAL) {
639639
/* use size suggested by the driver, if it knows it */
640-
alloced = C->fetched_len + 1;
640+
buf = emalloc(C->fetched_len + 1);
641+
memcpy(buf, C->data, C->fetched_len);
642+
buf[C->fetched_len] = 0;
643+
used = C->fetched_len;
644+
} else {
645+
buf = estrndup(C->data, 256);
646+
used = 255; /* not 256; the driver NUL terminated the buffer */
641647
}
642-
643-
buf = emalloc(alloced);
644-
memcpy(buf, C->data, 256);
645-
used = 255; /* not 256; the driver NUL terminated the buffer */
646648

647649
do {
648650
C->fetched_len = 0;

0 commit comments

Comments
 (0)