Skip to content

Commit

Permalink
CID 248378: Division or modulo by float zero (DIVIDE_BY_ZERO)
Browse files Browse the repository at this point in the history
2. divide_by_zero: In expression 32f /
static_cast<GLfloat>(cfg.checkSize(false)), division by expression
cfg.checkSize(false) which may be zero has undefined behavior.
  • Loading branch information
hallarempt committed Sep 26, 2019
1 parent f0c028d commit cc80eb9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libs/ui/kis_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -873,11 +873,16 @@ void KisConfig::saveSnapConfig(const KisSnapConfig &config)

qint32 KisConfig::checkSize(bool defaultValue) const
{
return (defaultValue ? 32 : m_cfg.readEntry("checksize", 32));
qint32 size = (defaultValue ? 32 : m_cfg.readEntry("checksize", 32));
if (size == 0) size = 32;
return size;
}

void KisConfig::setCheckSize(qint32 checksize) const
{
if (checksize == 0) {
checksize = 32;
}
m_cfg.writeEntry("checksize", checksize);
}

Expand Down

0 comments on commit cc80eb9

Please sign in to comment.