0

[PDF Ink Signatures] Fix incorrect numeric limit

Fix getting the wrong numeric limit for the InkStrokeId, which would be
0. This caused a PDF renderer crash when the user would draw 2 strokes,
undo, and draw a new stroke, triggering a reuse of an InkStrokeId of 0
and failing the numeric limit comparison CHECK.

For a safer merge, a regression test will be added in a future CL.

Bug: 378724153
Change-Id: I6482866c4be8401215275bf54de33451633ab91d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6019206
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382460}
This commit is contained in:
Andy Phan
2024-11-13 18:23:13 +00:00
committed by Chromium LUCI CQ
parent dac0a02343
commit 37f83aaf22

@ -1074,7 +1074,8 @@ void PdfInkModule::ApplyUndoRedoDiscards(
if (max_stroke_id.has_value()) {
// Since some stroke(s) got discarded, the maximum stroke ID value cannot be
// the max integer value. Thus adding 1 will not overflow.
CHECK_NE(max_stroke_id.value(), std::numeric_limits<InkStrokeId>::max());
CHECK_NE(max_stroke_id.value(),
InkStrokeId(std::numeric_limits<size_t>::max()));
stroke_id_generator_.ResetIdTo(
InkStrokeId(max_stroke_id.value().value() + 1));
} else {