From fa0dee19e2259194f3d3d797f83917e92385df8f Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 4 Aug 2024 17:02:29 -0400 Subject: Add comment --- builtins/array.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtins/array.c b/builtins/array.c index fe1712e7..aa6929d5 100644 --- a/builtins/array.c +++ b/builtins/array.c @@ -602,6 +602,8 @@ public void Array$heapify(array_t *heap, closure_t comparison, int64_t padded_it if (heap->data_refcount != 0) Array$compact(heap, padded_item_size); + // It's necessary to bump the refcount because the user's comparison + // function could do stuff that modifies the heap's data. ARRAY_INCREF(*heap); int64_t i, n = heap->length; for (i = (n >> 1) - 1 ; i >= 0 ; i--) -- cgit v1.2.3