From 4dbee3a3f13657577f283bca22b281d7273c19e5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 7 Dec 2017 22:35:59 +0100 Subject: 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. --- nxcomp/src/Misc.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nxcomp/src/Misc.h') 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. // -- cgit v1.2.3