[splint-discuss] DIR *dire storage created but not released??
Greg White
pcguy11 at live.com
Thu Nov 6 17:16:42 PST 2008
I ran splint on some source code that compiles with no errors using -Wall and works great. I get:
main.c:29: Include file matches the name of a POSIX library,
but the POSIX library is not being used. Consider using +posixlib or
+posixstrictlib to select the POSIX library, or -warnposix to suppress
this message.
main.c: (in function findfiles)
main.c:79:2: Fresh storage dire not released before return
A memory leak has been detected. Storage allocated locally is not
released before the last reference to it is lost. (Use -mustfreefresh to
inhibit warning)
main.c:58:3: Fresh storage dire created
#include
DIR *dire;
struct dirent *filea;
dire = opendir("./");
if (dire == NULL) {
perror ("Couldn't open the directory");
exit(EXIT_FAILURE);
}
while ((filea = readdir (dire))) {
printf("filename %s\n", filea->d_name);
}
(void) closedir (dire);
As you can see I close what I open, but splint still sees a memory leak. Can splint be educated about closedir so I don't get this error? Yes I could do -mustfreefresh to suppress the error but I would rather have splint fixed.
Also can someone please explain the POSIX library thing?
Thanks,
_________________________________________________________________
You live life beyond your PC. So now Windows goes beyond your PC.
http://clk.atdmt.com/MRT/go/115298556/direct/01/
More information about the splint-discuss
mailing list