path: root/src/corelib/codecs
diff options
authorGiuseppe D'Angelo <>2015-01-04 22:53:41 +0100
committerGiuseppe D'Angelo <>2015-01-05 15:51:01 +0100
commit8a4099a0aa86969744d1258244abf2b8d3e8ed26 (patch)
tree3d510cad2df3417d6467901bdf47881cf134f59e /src/corelib/codecs
parentbc7243d5832e466772734e24991025e0e8b067b0 (diff)
QIsciiCodec: add an assert to silence Coverity
Coverity (not rightfully) complains that the code is using "iscii", a uchar obtained by looking up into a table, as an index into the "uni_to_iscii_pairs" array. Since the array is only 18 elements long, there's the theoretic risk of accessing it past its end. However, the lookup of "iscii" never returns values that may actually go out of bounds. Coverity may be smart enough to see the values that "iscii" can get and not raise the warning, but since it does, make the code more robust and add an assert. Task-number: QTBUG-43642 Change-Id: Id75ca105758b343102ca94137d0379c10e55581a Reviewed-by: Olivier Goffart <>
Diffstat (limited to 'src/corelib/codecs')
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/codecs/qisciicodec.cpp b/src/corelib/codecs/qisciicodec.cpp
index e0c33aaa50..bd3b31667c 100644
--- a/src/corelib/codecs/qisciicodec.cpp
+++ b/src/corelib/codecs/qisciicodec.cpp
@@ -212,6 +212,7 @@ QByteArray QIsciiCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
if (iscii > 0x80) {
*ch++ = iscii;
} else if (iscii) {
+ Q_ASSERT((2 * iscii) < (sizeof(uni_to_iscii_pairs) / sizeof(uni_to_iscii_pairs[0])));
const uchar *pair = uni_to_iscii_pairs + 2*iscii;
*ch++ = *pair++;
*ch++ = *pair++;