Menu ▾ ▴

#2 Memory leak in sfs

open
nobody
None
5
2001-12-06
2001-12-06
No

PtPTL version 0.2

Bug
---
The 'sfs' sample application in ptptl/samples/sfs has
a memory leak. Memory allocated in sfs.cpp on
line 1214: char *s = new char[23];
is not freed.

To verify the bug
-----------------
1. Add the following line to ptptl/Makefile.cfg
_DEBUG = 1

2. Recompile ptp and the samples. This injects the
debug library, allowing us to track invocations
of 'new' and 'delete'.

3. In ptptl/samples/sfs
./sfs
This brings you to the sfs prompt (sfs) where you
type in 'quit'. The Debug library produces a dump of
the memory leak at this point along with the cause of
the leak.

Fix
---
Replace line 1244

return 0;

with:

delete s;
return 0;

Discussion


Log in to post a comment.