diff options
author | Simo Sorce <idra@samba.org> | 2002-04-16 22:56:08 +0000 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2002-04-16 22:56:08 +0000 |
commit | 18d5ffd835165d2570443c979d9157e2388b37d8 (patch) | |
tree | 239c4c22f76b60379c785a6d2a19f32b1cb079ec | |
parent | a538efe7d00e7a61df194ca1c22e0583dcbb7a4a (diff) | |
download | samba-18d5ffd835165d2570443c979d9157e2388b37d8.tar.gz samba-18d5ffd835165d2570443c979d9157e2388b37d8.tar.xz samba-18d5ffd835165d2570443c979d9157e2388b37d8.zip |
sync with 2.2
-rw-r--r-- | source/lib/snprintf.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/source/lib/snprintf.c b/source/lib/snprintf.c index 3034dfaaf68..27336261086 100644 --- a/source/lib/snprintf.c +++ b/source/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 */ |