From a39a25694d8b86a89ce1dd06d6f3bfade448202d Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Tue, 6 Sep 2022 06:51:45 +0100 Subject: [PATCH] Batching - fix uninitialized color read Valgrind was showing a read from uninitialized memory. r_fill_state.curr_batch->color is unset (for performance reasons), so can contain random data. This actually doesn't matter in practice, since logically this uninitialized state can only occur when change_batch is set, and the only side effect is that change_batch is set. Hence why no bugs occur in practice. This PR prevents this read from uninitialized data. It is likely free in terms of performance after optimization, and keeps the Valgrind logs clearer, so why not. --- drivers/gles_common/rasterizer_canvas_batcher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gles_common/rasterizer_canvas_batcher.h b/drivers/gles_common/rasterizer_canvas_batcher.h index f73392d22..9a426e13b 100644 --- a/drivers/gles_common/rasterizer_canvas_batcher.h +++ b/drivers/gles_common/rasterizer_canvas_batcher.h @@ -1334,7 +1334,7 @@ PREAMBLE(bool)::_prefill_line(RasterizerCanvas::Item::CommandLine *p_line, FillS // if the color has changed we need a new batch // (only single color line batches supported so far) - if (r_fill_state.curr_batch->color != bcol) { + if (!change_batch && r_fill_state.curr_batch->color != bcol) { change_batch = true; }