mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
CylindersModel: clamp the "cylinderuse" values
If the value for "use" is negative or larger than the number of elements in "enum cylinderuse", later CylindersModel::data() can request a string in the lines of cylinderuse_text[cyl->cylinder_use], which can SIGSEGV. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
56ed3f1c61
commit
cae99471ad
1 changed files with 4 additions and 1 deletions
|
@ -273,7 +273,10 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
break;
|
||||
case USE:
|
||||
if (CHANGED()) {
|
||||
cyl->cylinder_use = (enum cylinderuse)vString.toInt();
|
||||
int use = vString.toInt();
|
||||
if (use > NUM_GAS_USE - 1 || use < 0)
|
||||
use = 0;
|
||||
cyl->cylinder_use = (enum cylinderuse)use;
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue