From: Stanislav Malyshev Date: Thu, 8 Mar 2007 22:57:02 +0000 (+0000) Subject: MFB: fix crash/leak in bug #38710 X-Git-Tag: RELEASE_1_0_1~66 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=031991d7a7b4899ed7e440a939487ce0117aa821;p=php MFB: fix crash/leak in bug #38710 --- 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;