Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libheaptrace: Fix segfaults when directly using LD_PRELOAD
The current usage of 'heaptrace' works fine as follows. $ heaptrace samples/sample.out [heaptrace] initialized for /proc/4084/maps (sample.out) [heaptrace] finalized for /proc/4084/maps (sample.out) It should be fine when running it with 'LD_PRELOAD' without using 'heaptrace' helper binary, but it gets crashed as follows. $ LD_PRELOAD=./libheaptrace.so samples/sample.out Segmentation falut (core dumped) The problem is because 'getenv()' returns NULL in this case, but it misses to check whether the returned values are NULL or not. This patch fixes this problem and it makes LD_PRELOAD usage works fine. $ LD_PRELOAD=./libheaptrace.so samples/sample.out [heaptrace] initialized for /proc/4167/maps (sample.out) [heaptrace] finalized for /proc/4167/maps (sample.out) Fixed: #18 Reported-by: Bojun Seo <[email protected]> Signed-off-by: Honggyu Kim <[email protected]>
- Loading branch information