From c9bf53c2523d85dae24a297357bc9b2667d00b58 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 10 Dec 2022 12:33:16 -0800 Subject: [PATCH] cgraph: fix incorrect resize-down implementation for lists without destructors Attempting to shrink a list that did not have a element destructor would incorrectly do nothing. --- lib/cgraph/list.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cgraph/list.h b/lib/cgraph/list.h index e7f4c2351..044b1dd24 100644 --- a/lib/cgraph/list.h +++ b/lib/cgraph/list.h @@ -145,11 +145,11 @@ } \ } else if (list->size > size) { \ /* we are shrinking the list */ \ - if (list->dtor != NULL) { \ - while (list->size > size) { \ + while (list->size > size) { \ + if (list->dtor != NULL) { \ list->dtor(list->data[list->size - 1]); \ - --list->size; \ } \ + --list->size; \ } \ } \ } \ -- 2.50.1