Fix memory leak in path coverage by freeing graph data.
A memory leak in path coverage analysis has been fixed by ensuring graph data is freed.
A memory leak in the path coverage analysis tool has been resolved by adding a call to free_graph. Previously, graph data allocated for analyzing prime paths was not being deallocated, leading to memory loss.
This fix addresses a memory management issue identified through tools like Valgrind, improving the stability and resource usage of the coverage analysis feature.
In Details
The cfg_as_graph function in path-coverage.cc returns a pointer to a dynamically allocated graph structure. The documentation for this function, as noted in the commit, specifies that the caller is responsible for freeing this memory using free_graph. The find_prime_paths function was missing this call, leading to a memory leak. This commit adds the necessary free_graph call to find_prime_paths.
- Valgrind
- A instrumentation framework for dynamic analysis, commonly used for memory debugging, memory leak detection, and profiling.
- cfg_as_graph
- A function that converts a control flow graph (CFG) into a graph data structure suitable for algorithms like finding prime paths. It dynamically allocates memory for the graph.
- free_graph
- A function responsible for deallocating the memory previously allocated for a graph structure, typically returned by functions like
cfg_as_graph.