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.
This commit is contained in:
lawnjelly 2022-09-06 06:51:45 +01:00
parent 4d4c6c187d
commit 23fedc0d1a
1 changed files with 1 additions and 1 deletions

View File

@ -1335,7 +1335,7 @@ PREAMBLE(bool)::_prefill_line(RasterizerCanvas::Item::CommandLine *p_line, FillS
// if the color has changed we need a new batch // if the color has changed we need a new batch
// (only single color line batches supported so far) // (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; change_batch = true;
} }