浏览代码

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.
lawnjelly 3 年之前
父节点
当前提交
23fedc0d1a
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/gles_common/rasterizer_canvas_batcher.h

+ 1 - 1
drivers/gles_common/rasterizer_canvas_batcher.h

@@ -1335,7 +1335,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;
 	}