Fix possible crash in QTextDocument
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Tue, 11 Dec 2012 13:07:16 +0000 (14:07 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 3 Jan 2013 15:15:37 +0000 (16:15 +0100)
commit248ccb2889aec76cb99c25998534c97b48b98c4a
tree245b07bbef790f3f87fdcd7406dfe1efb5f76f59
parent4319f698c893683c6a031e41272b85cfb25ac931
Fix possible crash in QTextDocument

With trailing spaces in some cases, we would not get the
"no justification at end of paragraph" special case, and continue
in the code, getting the unexpected case where line_length becomes
< 0 which would lead to memory corruption because we were writing
outside our buffers. I added an assert to catch this type of bug
earlier, and I added the trailing spaces to the test for the end
of the paragraph.

The test case added is one example which would crash.

Task-number: QTBUG-27354
Change-Id: Id720a6fa55dbc709ce04dd5321e55687bf960d75
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/gui/text/qtextengine.cpp
tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp