Skip to content

Commit 064cf12

Browse files
Ben WagnerSkCQ
authored andcommitted
Better bounds check idIndex in ImGuiLayer
If the paint pointer references the upper half of memory the intptr_t will be negative, which is not a value that is intended as an index into fSkiaWidgetFuncs. Fixing this bounds check avoids a crash in viewer on Android. Change-Id: I0f90cca53d8ea01333bf1bedf5464aa2e074b9b4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1051338 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Florin Malita <fmalita@google.com> Commit-Queue: Florin Malita <fmalita@google.com> Auto-Submit: Ben Wagner <bungeman@google.com>
1 parent ba9ba38 commit 064cf12

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/viewer/ImGuiLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void ImGuiLayer::onPaint(SkSurface* surface) {
195195
drawCmd->UserCallback(drawList, drawCmd);
196196
} else {
197197
intptr_t idIndex = (intptr_t)drawCmd->TextureId;
198-
if (idIndex < fSkiaWidgetFuncs.size()) {
198+
if (0 <= idIndex && idIndex < fSkiaWidgetFuncs.size()) {
199199
// Small image IDs are actually indices into a list of callbacks. We directly
200200
// examing the vertex data to deduce the image rectangle, then reconfigure the
201201
// canvas to be clipped and translated so that the callback code gets to use

0 commit comments

Comments
 (0)