From cc80eb9edeb2517bb7965c228f07b59ad11956c3 Mon Sep 17 00:00:00 2001 From: Boudewijn Rempt Date: Thu, 26 Sep 2019 15:14:33 +0200 Subject: [PATCH] CID 248378: Division or modulo by float zero (DIVIDE_BY_ZERO) 2. divide_by_zero: In expression 32f / static_cast(cfg.checkSize(false)), division by expression cfg.checkSize(false) which may be zero has undefined behavior. --- libs/ui/kis_config.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/ui/kis_config.cc b/libs/ui/kis_config.cc index 450d5d38a7..0823c90c35 100644 --- a/libs/ui/kis_config.cc +++ b/libs/ui/kis_config.cc @@ -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); }