You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Memory Leak in leveldb_filterpolicy_create_bloom Function
Body
Description
There appears to be a potential memory leak in the implementation of leveldb_filterpolicy_create_bloom in db/c.cc. The leak occurs when an instance of Wrapper, which internally manages a FilterPolicy object, is not properly destroyed under certain conditions, leading to memory not being freed.
Leak Details
The function creates a Wrapper object, which owns a FilterPolicy instance allocated by NewBloomFilterPolicy.
The Wrapper destructor is supposed to manage the lifecycle of the FilterPolicy instance. However, if an exception or an early return occurs before the Wrapper object is assigned to a managing pointer or if the leveldb_filterpolicy_destroy function does not perform the deletion correctly, the allocated memory is not freed, resulting in a memory leak.
Steps to Reproduce
Call leveldb_filterpolicy_create_bloom with a specific bits_per_key.
Simulate an exception or an early return before the function completes.
Observe that the memory allocated for the FilterPolicy instance is not freed.
Expected Behavior
All allocated memory should be properly managed and freed when no longer needed.
Possible Fix
Ensure that all error paths and exceptional conditions are handled appropriately, and that the leveldb_filterpolicy_destroy function correctly deletes the Wrapper object.
System Information
Operating System: [Your Operating System]
Architecture: [e.g., x86_64]
LevelDB Version: [Specify the version or commit hash]
Additional Information
Please consider reviewing the exception safety of the function to ensure that resources are always released correctly, regardless of the execution path.
Labels
bug, memory-leak
The text was updated successfully, but these errors were encountered:
Title
Memory Leak in leveldb_filterpolicy_create_bloom Function
Body
Description
There appears to be a potential memory leak in the implementation of
leveldb_filterpolicy_create_bloom
indb/c.cc
. The leak occurs when an instance ofWrapper
, which internally manages aFilterPolicy
object, is not properly destroyed under certain conditions, leading to memory not being freed.Leak Details
Wrapper
object, which owns aFilterPolicy
instance allocated byNewBloomFilterPolicy
.Wrapper
destructor is supposed to manage the lifecycle of theFilterPolicy
instance. However, if an exception or an early return occurs before theWrapper
object is assigned to a managing pointer or if theleveldb_filterpolicy_destroy
function does not perform the deletion correctly, the allocated memory is not freed, resulting in a memory leak.Steps to Reproduce
leveldb_filterpolicy_create_bloom
with a specificbits_per_key
.FilterPolicy
instance is not freed.Expected Behavior
All allocated memory should be properly managed and freed when no longer needed.
Possible Fix
Ensure that all error paths and exceptional conditions are handled appropriately, and that the
leveldb_filterpolicy_destroy
function correctly deletes theWrapper
object.System Information
Additional Information
Please consider reviewing the exception safety of the function to ensure that resources are always released correctly, regardless of the execution path.
Labels
bug, memory-leak
The text was updated successfully, but these errors were encountered: