Skip to content
Permalink
Browse files

Merge pull request #9064 from mhugo/fix_20831

Avoid undefined behaviour with signed integer overflow
  • Loading branch information
Hugo Mercier
Hugo Mercier committed Feb 4, 2019
2 parents e953141 + 5609f4a commit ed45181bee3dfe7e1de98a58a7011a027f66a20e
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/gui/editorwidgets/qgsrangewidgetwrapper.cpp
@@ -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 ) );

0 comments on commit ed45181

Please sign in to comment.
You can’t perform that action at this time.