Skip to content

Commit 601d17d

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO).
1 parent 8665e02 commit 601d17d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ PHP NEWS
4747
. Fixed bug #61194 (PDO should export compression flag with myslqnd).
4848
(Johannes)
4949

50+
- PDO_odbc
51+
. Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO). (Ilia)
52+
5053
- PDO_pgsql
5154
. Fixed bug #61267 (pdo_pgsql's PDO::exec() returns the number of SELECTed
5255
rows on postgresql >= 9). (ben dot pineau at gmail dot com)

ext/pdo_odbc/odbc_stmt.c

+7-5
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)