]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Shouldn't need to specify ctx... but maybe this will fix the leak?
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 19 Aug 2021 00:04:52 +0000 (19:04 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 19 Aug 2021 00:04:52 +0000 (19:04 -0500)
src/lib/util/heap.c

index 494c3867ec948e8bd4dbc42bb79706ac8aa189a2..9665c092857146331413819ca0876f57ec1bf1c0 100644 (file)
@@ -72,7 +72,7 @@ static void fr_heap_bubble(heap_t *h, fr_heap_index_t child);
  */
 size_t fr_heap_pre_alloc_size(unsigned int count)
 {
-       return sizeof(fr_heap_t) + sizeof(void *) * count;
+       return sizeof(fr_heap_t) + sizeof(heap_t) + sizeof(void *) * count;
 }
 
 fr_heap_t *_fr_heap_alloc(TALLOC_CTX *ctx, fr_heap_cmp_t cmp, char const *type, size_t offset, unsigned int init)
@@ -187,7 +187,7 @@ int fr_heap_insert(fr_heap_t *hp, void *data)
                        n_size = h->size * 2;
                }
 
-               h = (heap_t *)talloc_realloc(NULL, h, uint8_t, sizeof(heap_t) + (sizeof(void *) * (n_size + 1)));
+               h = (heap_t *)talloc_realloc(hp, h, uint8_t, sizeof(heap_t) + (sizeof(void *) * (n_size + 1)));
                if (unlikely(!h)) {
                        fr_strerror_printf("Failed expanding heap to %u elements (%u bytes)",
                                           n_size, (n_size * (unsigned int)sizeof(void *)));