summaryrefslogtreecommitdiff
path: root/xfa/fgas/layout
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-08-02 14:44:17 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-02 19:02:41 +0000
commitdb14532fb2637b34f0926b6c3a931132854f53bb (patch)
tree322bdae3c8ee7812a182f88def802e28fbc34675 /xfa/fgas/layout
parent4a0cbf9f0cb4f7e3bcbae68f82201b44fc94c231 (diff)
downloadpdfium-db14532fb2637b34f0926b6c3a931132854f53bb.tar.xz
Rewrite how string Insert() methods handle out of bound indices
The existing behaviour was to clamp the provided index to the valid bounds. This would lead to programming errors being hidden, since inserting would still do something even if the index calculation was wrong. The behaviour of these methods has been changed to instead early return when this occurs, returning the old length value. The caller can check if the call to Insert actually did anything by comparing the returned value to the length before calling insert. All of the existing calls to Insert have been tested by running all of the tests with asserts in the Insert method to check the index is in bounds. Additionally the call sites have been manually inspected. The majority of them are of the form Insert(0, foo) and the rest tend to be in a loop advancing from 0 to length. Convenience methods InsertAtFront/InsertAtBack have been added to handle calling Insert when the intent is for the character to be added to the beginning or end of the string. Existing call sites to Insert that do this have been converted. This work was originally being performed to check if there would be any issues in these methods with making FX_STRSIZE unsigned. BUG=pdfium:828 Change-Id: I60cee5ad45338aa8ed46569de7bcc78a76db18f7 Reviewed-on: https://pdfium-review.googlesource.com/9870 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fgas/layout')
0 files changed, 0 insertions, 0 deletions