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>
#ifndef SMB_ICONV_BUFSIZE
#define SMB_ICONV_BUFSIZE 2048
#endif
#ifndef SMB_ICONV_BUFSIZE
#define SMB_ICONV_BUFSIZE 2048
#endif
- 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;
while (*inbytesleft > 0) {
char *bufp1 = cvtbuf;
if (cd->push(cd->cd_push,
&bufp2, &bufsize,
outbuf, outbytesleft) == -1) {
if (cd->push(cd->cd_push,
&bufp2, &bufsize,
outbuf, outbytesleft) == -1) {
return -1;
} else if (pull_failed) {
/* We want the pull errno if possible */
return -1;
} else if (pull_failed) {
/* We want the pull errno if possible */