diff options
| author | Volker Lendecke <vl@samba.org> | 2013-12-06 10:31:07 +0000 |
|---|---|---|
| committer | Stefan Metzmacher <metze@samba.org> | 2013-12-14 10:06:28 +0100 |
| commit | 70dfb51430bc3b6e436fb5c5452d7ef8612ca02f (patch) | |
| tree | d6602a2bdb8f4ff61e13665c586bec2490e71e59 /lib/util/charset | |
| parent | a9753c180fbd06764987367fe3115159cdef4330 (diff) | |
| download | samba-70dfb51430bc3b6e436fb5c5452d7ef8612ca02f.tar.gz samba-70dfb51430bc3b6e436fb5c5452d7ef8612ca02f.tar.xz samba-70dfb51430bc3b6e436fb5c5452d7ef8612ca02f.zip | |
iconv: Use a static buffer in iconf not to spoil the talloc_pool
This is a buffer that is strictly used like a stack variable. This
patch makes it one and while there it fixes an error path memleak.
In the "pull_failed" case we did not talloc_free(cvtbuf). With
talloc_tos(), this does not really matter, but for code without
this it does.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/util/charset')
| -rw-r--r-- | lib/util/charset/iconv.c | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c index 1c507b4b13..c5b45fe975 100644 --- a/lib/util/charset/iconv.c +++ b/lib/util/charset/iconv.c @@ -127,20 +127,8 @@ _PUBLIC_ size_t smb_iconv(smb_iconv_t cd, #ifndef SMB_ICONV_BUFSIZE #define SMB_ICONV_BUFSIZE 2048 #endif - TALLOC_CTX *mem_ctx; size_t bufsize; - char *cvtbuf; - -#if _SAMBA_BUILD_ == 3 - mem_ctx = talloc_tos(); -#else - mem_ctx = cd; -#endif - cvtbuf = talloc_array(mem_ctx, char, SMB_ICONV_BUFSIZE); - - if (!cvtbuf) { - return (size_t)-1; - } + char cvtbuf[SMB_ICONV_BUFSIZE]; while (*inbytesleft > 0) { char *bufp1 = cvtbuf; @@ -161,7 +149,6 @@ _PUBLIC_ size_t smb_iconv(smb_iconv_t cd, if (cd->push(cd->cd_push, &bufp2, &bufsize, outbuf, outbytesleft) == -1) { - talloc_free(cvtbuf); return -1; } else if (pull_failed) { /* We want the pull errno if possible */ @@ -169,7 +156,6 @@ _PUBLIC_ size_t smb_iconv(smb_iconv_t cd, return -1; } } - talloc_free(cvtbuf); } return 0; |
