Skip to content

Commit 283accd

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO).
1 parent 18a4e93 commit 283accd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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)