mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 02:42:55 +00:00
avoid temporary in QImageData::create()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
0e44c3b18a
commit
d418199d5c
1 changed files with 7 additions and 6 deletions
|
@ -610,19 +610,20 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm
|
|||
return Q_NULLPTR;
|
||||
|
||||
const int depth = qt_depthForFormat(format);
|
||||
const int calc_bytes_per_line = ((width * depth + 31)/32) * 4;
|
||||
const int min_bytes_per_line = (width * depth + 7)/8;
|
||||
|
||||
if (bpl <= 0)
|
||||
bpl = calc_bytes_per_line;
|
||||
if (bpl <= 0) {
|
||||
bpl = ((width * depth + 31)/32) * 4;
|
||||
}
|
||||
|
||||
if (width <= 0 || height <= 0 || !data
|
||||
if (Q_UNLIKELY(width <= 0 || height <= 0 || !data
|
||||
|| INT_MAX/sizeof(uchar *) < uint(height)
|
||||
|| INT_MAX/uint(depth) < uint(width)
|
||||
|| bpl <= 0
|
||||
|| bpl < min_bytes_per_line
|
||||
|| INT_MAX/uint(bpl) < uint(height))
|
||||
return Q_NULLPTR; // invalid parameter(s)
|
||||
|| INT_MAX/uint(bpl) < uint(height))) {
|
||||
return Q_NULLPTR; // invalid parameter(s)
|
||||
}
|
||||
|
||||
QScopedPointer<QImageData> d(new QImageData);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue