vc4: use safe iterator to remove instructions

The current approach has an issue detected by static analyzer: use of
memory after it is freed.

Using a proper iterator makes things safer.

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34050>
This commit is contained in:
Juan A. Suarez Romero 2025-03-12 17:15:17 +01:00 committed by Marge Bot
parent baa4fefe74
commit 0b0d6a36f2

View file

@ -738,10 +738,7 @@ void
qir_compile_destroy(struct vc4_compile *c)
{
qir_for_each_block(block, c) {
while (!list_is_empty(&block->instructions)) {
struct qinst *qinst =
list_first_entry(&block->instructions,
struct qinst, link);
list_for_each_entry_safe(struct qinst, qinst, &block->instructions, link) {
qir_remove_instruction(c, qinst);
}
}