summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qringbuffer_p.h
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2018-01-05 18:51:20 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2018-01-10 20:21:31 +0000
commit344acfb9fed285f4f822c0fdc1b2ba22887c0f04 (patch)
tree6afc9118b4c26829ecccb8b7dd5a2841dc209f9d /src/corelib/tools/qringbuffer_p.h
parente56eb33cf852ea4f3228103b79f02874e01f081e (diff)
QRingBuffer: replace some checks with asserts
To avoid the silent exits and potentially dangerous output values, the caller must supply the correct parameters on input. Change-Id: Ia9c56940adbf4ad34605a002dfc5c86b32c4658c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/tools/qringbuffer_p.h')
-rw-r--r--src/corelib/tools/qringbuffer_p.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index c232ae3c72..76ab4a5b62 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -207,8 +207,9 @@ public:
Q_CORE_EXPORT char *reserveFront(qint64 bytes);
inline void truncate(qint64 pos) {
- if (pos < size())
- chop(size() - pos);
+ Q_ASSERT(pos >= 0 && pos <= size());
+
+ chop(size() - pos);
}
Q_CORE_EXPORT void chop(qint64 bytes);