Skip to content

Commit

Permalink
Avoid memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Nov 29, 2024
1 parent 62b3a29 commit 5066149
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Src/orbtop.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,19 @@ uint32_t _consolodateReport( struct reportLine **returnReport, uint32_t *returnR
}
else
{
a = ( struct visitedAddr * )calloc( 1, sizeof( struct visitedAddr ) );
MEMCHECKV( a );
a->visits = _r.sleeps;

n = ( struct nameEntry * )malloc( sizeof( struct nameEntry ) );
}
n->fileindex = NO_FILE;
n->functionindex = FN_SLEEPING;
n->addr = FN_SLEEPING;
n->line = 0;

n->fileindex = NO_FILE;
n->functionindex = FN_SLEEPING;
n->addr = 0;
n->line = 0;
a->n = n;
HASH_ADD_INT( _r.addresses, n->addr, a );
}

report[reportLines].n = n;
report[reportLines].count = _r.sleeps;
Expand Down Expand Up @@ -814,6 +820,7 @@ void _flushHash( void )
for ( a = _r.addresses; a != NULL; a = hh.next )
{
hh = a->hh;
if ( a->n ) free( a->n );
free( a );
}

Expand Down

0 comments on commit 5066149

Please sign in to comment.