From 031991d7a7b4899ed7e440a939487ce0117aa821 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Thu, 8 Mar 2007 22:57:02 +0000 Subject: MFB: fix crash/leak in bug #38710 --- ext/mysqli/mysqli_api.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ext/mysqli/mysqli_api.c') diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 41ccff187b..77af19f856 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -764,7 +764,16 @@ PHP_FUNCTION(mysqli_stmt_fetch) } #endif else { - ZVAL_UTF8_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val, stmt->result.buf[i].buflen, ZSTR_DUPLICATE); +#if defined(MYSQL_DATA_TRUNCATED) && MYSQL_VERSION_ID > 50002 + if(ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) != 0) { + /* result was truncated */ + ZVAL_UTF8_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val, stmt->stmt->bind[i].buffer_length, ZSTR_DUPLICATE); + } else { +#else + { +#endif + ZVAL_UTF8_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val, stmt->result.buf[i].buflen, ZSTR_DUPLICATE); + } } break; -- cgit v1.2.1