mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Merge pull request #9064 from mhugo/fix_20831
Avoid undefined behaviour with signed integer overflow
This commit is contained in:
commit
ed45181bee
@ -145,12 +145,12 @@ void QgsRangeWidgetWrapper::initWidget( QWidget *editor )
|
||||
int minval = min.toInt();
|
||||
if ( allowNull )
|
||||
{
|
||||
int stepval = step.isValid() ? step.toInt() : 1;
|
||||
int newMinval = minval - stepval;
|
||||
uint stepval = step.isValid() ? step.toUInt() : 1;
|
||||
// make sure there is room for a new value (i.e. signed integer does not overflow)
|
||||
if ( newMinval < minval )
|
||||
int minvalOverflow = uint( minval ) - stepval;
|
||||
if ( minvalOverflow < minval )
|
||||
{
|
||||
minval = newMinval;
|
||||
minval = minvalOverflow;
|
||||
}
|
||||
mIntSpinBox->setValue( minval );
|
||||
QgsSpinBox *intSpinBox( qobject_cast<QgsSpinBox *>( mIntSpinBox ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user