diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-03-25 08:09:03 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-03-25 08:02:31 +0000 |
commit | 5ca7d56aca5d7cae3f6eefad181839f9b3a2ece6 (patch) | |
tree | 48aa26a37bb233daa2c7311c45f804ac158fdf6b /src/corelib | |
parent | e19fda916aa92f8890199dc4b9d56884c55d0cd8 (diff) |
QVarLengthArray: fix compilation with GCC 7
This fixes a warning-turned-Werror in qdistancefield.cpp:
In member function ‘void QVarLengthArray<T, Prealloc>::realloc(int, int) [with T = bool; int Prealloc = 256]’,
inlined from ‘void makeDistanceField(QDistanceFieldData*, const QPainterPath&, int, int)’ at ../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvarlengtharray.h:275:10:
../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvarlengtharray.h:390:19: error: ‘void* memcpy(void*, const void*, size_t)’: specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
memcpy(ptr, oldPtr, copySize * sizeof(T));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Apparently GCC cannot rule out that copySize may be negative in the
call to memcpy. Put GCC on the right track by adding a Q_ASSUME.
Change-Id: I63e3801e52ebe2a7f77e3a97ef03ec3869319c8c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 2d3c25a5dd..8b9df7c12b 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -350,6 +350,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a int osize = s; const int copySize = qMin(asize, osize); + Q_ASSUME(copySize >= 0); if (aalloc != a) { if (aalloc > Prealloc) { T* newPtr = reinterpret_cast<T *>(malloc(aalloc * sizeof(T))); |