From 2eec8d1846bb29bf753a34aefaebd301ef17de03 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 23 Sep 2023 11:18:41 +0200 Subject: Fix a couple of profiling memory errors The "children" array was the wrong size, and not freed. Also, some formatting fussiness. --- libcrystfel/src/profile.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libcrystfel/src/profile.c b/libcrystfel/src/profile.c index 75983af3..ac76b8fa 100644 --- a/libcrystfel/src/profile.c +++ b/libcrystfel/src/profile.c @@ -168,6 +168,7 @@ static void free_profile_block(struct _profile_block *b) for ( i=0; in_children; i++ ) { free_profile_block(b->children[i]); } + free(b->children); free(b->name); free(b); } @@ -217,9 +218,10 @@ void profile_start(const char *name) if ( pd->current->n_children >= pd->current->max_children ) { struct _profile_block **nblock; int nmax = pd->current->n_children + 64; - nblock = realloc(pd->current->children, nmax*sizeof(struct _profile_block)); + nblock = realloc(pd->current->children, nmax*sizeof(struct _profile_block *)); if ( nblock == NULL ) { - fprintf(stderr, "Failed to allocate profiling record. Try again without --profile.\n"); + fprintf(stderr, "Failed to allocate profiling record. " + "Try again without --profile.\n"); abort(); } pd->current->children = nblock; -- cgit v1.2.3