diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-03-25 08:09:03 +0100 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2017-03-27 08:30:53 +0000 |
commit | ebdd953e1a66ddb752a089f9bb9281a18966cc5f (patch) | |
tree | 76c8a38491a7f0071e2ffad0f988714aa8ef4b6c /src | |
parent | 7aebc2d0faa95b5e711c955613b745114a9f7a99 (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>
(cherry picked from commit 5ca7d56aca5d7cae3f6eefad181839f9b3a2ece6)
Diffstat (limited to 'src')
-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 1457b90af0..dd9e6fed94 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -344,6 +344,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))); |