aboutsummaryrefslogtreecommitdiff
path: root/nxcomp/src/Misc.h
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-12-07 22:35:59 +0100
committerMihai Moldovan <ionic@ionic.de>2017-12-09 13:15:35 +0100
commit4dbee3a3f13657577f283bca22b281d7273c19e5 (patch)
tree638d62dce7a3e1f4245cb53212e3e422f310be99 /nxcomp/src/Misc.h
parent2814677a7e2b259669708c89ed55b55dc1c46f9c (diff)
downloadnx-libs-4dbee3a3f13657577f283bca22b281d7273c19e5.tar.gz
nx-libs-4dbee3a3f13657577f283bca22b281d7273c19e5.tar.bz2
nx-libs-4dbee3a3f13657577f283bca22b281d7273c19e5.zip
nxcomp: use new macro SAFE_FREE(ptr)
Should be used instead of free() calls and will clear the pointer after calling free(). This can prevent double-free or use-after-free errors.
Diffstat (limited to 'nxcomp/src/Misc.h')
-rw-r--r--nxcomp/src/Misc.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/nxcomp/src/Misc.h b/nxcomp/src/Misc.h
index 997630137..7808c34c2 100644
--- a/nxcomp/src/Misc.h
+++ b/nxcomp/src/Misc.h
@@ -54,6 +54,9 @@ using namespace std;
#define EGET() (errno)
#define ESTR() strerror(errno)
+// a free() macro that clears the ptr after free
+#define SAFE_FREE(ptr) do { free(ptr); ptr = NULL; } while (0)
+
//
// TCP port offset applied to NX port specification.
//