summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2002-04-16 22:56:08 +0000
committerSimo Sorce <idra@samba.org>2002-04-16 22:56:08 +0000
commit1416106736adb6190ac788ee27c2a4bf4eb1790f (patch)
tree29fe516c9d874b023bc137e015d77487c273e358 /source3/lib
parent7c0301d100885f3d4ee48a973158d1aa0036af1c (diff)
downloadsamba-1416106736adb6190ac788ee27c2a4bf4eb1790f.tar.gz
samba-1416106736adb6190ac788ee27c2a4bf4eb1790f.tar.bz2
samba-1416106736adb6190ac788ee27c2a4bf4eb1790f.zip
sync with 2.2
(This used to be commit 18d5ffd835165d2570443c979d9157e2388b37d8)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/snprintf.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/source3/lib/snprintf.c b/source3/lib/snprintf.c
index 3034dfaaf6..2733626108 100644
--- a/source3/lib/snprintf.c
+++ b/source3/lib/snprintf.c
@@ -100,6 +100,11 @@
#define LLONG long
#endif
+/* free memory if the pointer is valid and zero the pointer */
+#ifndef SAFE_FREE
+#define SAFE_FREE(x) do { if ((x) != NULL) {free((x)); (x)=NULL;} } while(0)
+#endif
+
static size_t dopr(char *buffer, size_t maxlen, const char *format,
va_list args);
static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
@@ -822,10 +827,10 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
{
char *msg = NULL;
vasprintf(&msg, format, arglist);
- if (!msg)
- return;
- syslog(facility_priority, "%s", msg);
- free(msg);
+ if (!msg)
+ return;
+ syslog(facility_priority, "%s", msg);
+ SAFE_FREE(msg);
}
#endif /* HAVE_SYSLOG */
#endif /* HAVE_VSYSLOG */