diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2018-01-05 18:51:20 +0200 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2018-01-10 20:21:31 +0000 |
commit | 344acfb9fed285f4f822c0fdc1b2ba22887c0f04 (patch) | |
tree | 6afc9118b4c26829ecccb8b7dd5a2841dc209f9d /src/corelib/tools/qringbuffer_p.h | |
parent | e56eb33cf852ea4f3228103b79f02874e01f081e (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.h | 5 |
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); |