www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples

Archive Index This month's Index

Subject: NULL after *_free?

NULL after *_free?

From: Neil Gierman <ngierman_at_roadrunn.com>
Date: Thu, 11 Feb 2010 14:56:54 -0600

I was running across some crashes in my code and while I think the original
crash was not due to libssh2, I saw some things in libssh2 that I don't know
are optimal. In libssh2_session_free and libssh2_channel_free, we do free()
the memory and then leave the pointer to whatever. In debug versions of VC++
binaries, free'd pointers are given a specific address (0xFEEEFEEE) to
signify to the debugger that the memory has been free()'d. The problem in my
code is I have a FREE macro that checks if a pointer is NULL and if not,
free()'s it. You can image the rest, a pointer of 0xFEEEFEEE is not NULL but
free()ing that will be bad. Should we set pointers to NULL after free()'ing
them, or is that the responsibility of the application?

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-02-11

the libssh2 team