postgres.git / summary / log / commit / refs

commit    25ee58e8f26df9ce3037258206eb100a3fc55103
Author:   Andres Freund <andres@anarazel.de>
Date:     Mon Apr 08 02:00:11 2024 +0000
First released in: 17.0, 12.19, 13.15, 14.12, 15.7, 16.3

    simplehash: Free collisions array in SH_STAT
    
    While SH_STAT() is only used for debugging, the allocated array can be large,
    and therefore should be freed.
    
    It's unclear why coverity started warning now.
    
    Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
    Reported-by: Coverity
    Discussion: https://postgr.es/m/3005248.1712538233@sss.pgh.pa.us
    Backpatch: 12-


src/include/lib/simplehash.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.h index 548526f7615..85a1448d2fb 100644 --- a/src/include/lib/simplehash.h +++ b/src/include/lib/simplehash.h @@ -1102,6 +1102,9 @@ SH_STAT(SH_TYPE * tb) max_collisions = curcoll; } + /* large enough to be worth freeing, even if just used for debugging */ + pfree(collisions); + if (tb->members > 0) { fillfactor = tb->members / ((double) tb->size); [parent: 7a0541301078]