--- embedaddon/php/ext/pdo_odbc/odbc_stmt.c 2012/02/21 23:47:59 1.1.1.1 +++ embedaddon/php/ext/pdo_odbc/odbc_stmt.c 2012/05/29 12:34:41 1.1.1.2 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: odbc_stmt.c,v 1.1.1.1 2012/02/21 23:47:59 misho Exp $ */ +/* $Id: odbc_stmt.c,v 1.1.1.2 2012/05/29 12:34:41 misho Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -637,12 +637,14 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int col 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;