From: Matthew Fernandez Date: Sat, 10 Dec 2022 20:33:16 +0000 (-0800) Subject: cgraph: fix incorrect resize-down implementation for lists without destructors X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9bf53c2523d85dae24a297357bc9b2667d00b58;p=graphviz 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. --- 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; \ } \ } \ } \