From 74705ae17b29ad560d1d6ad741bdb065ad7a0751 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 13 Aug 2021 17:56:11 -0700 Subject: [PATCH] MySQL: don't allocate 1-byte buffers for BLOBs We set the buffer length to 0 for blobs, as we need to do it for each row, in bindBlobs() (apparently a workaround for MySQL 4.1.8 API). That function was deleting the buffer and reallocating. Change-Id: I4a40ccbd3321467a8429fffd169b06422612ca13 Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index 95d5bb3b121..69077f2fc8d 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -364,7 +364,7 @@ bool QMYSQLResultPrivate::bindInValues() bind->length = &f.bufLength; bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0; - char *field = new char[bind->buffer_length + 1]{}; + char *field = bind->buffer_length ? new char[bind->buffer_length + 1]{} : nullptr; bind->buffer = f.outField = field; ++i;