summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authortodd stecher <todd.stecher@gmail.com>2009-01-19 15:09:51 -0800
committerSteven Danneman <steven.danneman@isilon.com>2009-01-21 17:13:03 -0800
commit989ad44d32c2e77972a966d91f1813b0b929f83b (patch)
treebb7a41c961fe974f464f7ce2a27ca3bf055187bf /source3/lib
parente9615b43b4dc7037da7bc274d720b8e54c7f85bc (diff)
downloadsamba-989ad44d32c2e77972a966d91f1813b0b929f83b.tar.gz
samba-989ad44d32c2e77972a966d91f1813b0b929f83b.tar.bz2
samba-989ad44d32c2e77972a966d91f1813b0b929f83b.zip
Memory leaks and other fixes found by Coverity
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dprintf.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/source3/lib/dprintf.c b/source3/lib/dprintf.c
index b3c830dd5b..631c45a807 100644
--- a/source3/lib/dprintf.c
+++ b/source3/lib/dprintf.c
@@ -32,24 +32,27 @@
int d_vfprintf(FILE *f, const char *format, va_list ap)
{
- char *p, *p2;
+ char *p = NULL, *p2 = NULL;
int ret, maxlen, clen;
const char *msgstr;
va_list ap2;
+ va_copy(ap2, ap);
+
/* do any message translations */
msgstr = lang_msg(format);
- if (!msgstr) return -1;
-
- va_copy(ap2, ap);
+ if (!msgstr) {
+ ret = -1;
+ goto out;
+ }
ret = vasprintf(&p, msgstr, ap2);
lang_msg_free(msgstr);
if (ret <= 0) {
- va_end(ap2);
- return ret;
+ ret = -1;
+ goto out;
}
/* now we have the string in unix format, convert it to the display
@@ -58,10 +61,10 @@
again:
p2 = (char *)SMB_MALLOC(maxlen);
if (!p2) {
- SAFE_FREE(p);
- va_end(ap2);
- return -1;
+ ret = -1;
+ goto out;
}
+
clen = convert_string(CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen, True);
if (clen >= maxlen) {
@@ -72,10 +75,11 @@ again:
}
/* good, its converted OK */
- SAFE_FREE(p);
ret = fwrite(p2, 1, clen, f);
- SAFE_FREE(p2);
+out:
+ SAFE_FREE(p);
+ SAFE_FREE(p2);
va_end(ap2);
return ret;