diff options
author | Rafal Szczesniak <mimir@samba.org> | 2003-07-13 16:25:55 +0000 |
---|---|---|
committer | Rafal Szczesniak <mimir@samba.org> | 2003-07-13 16:25:55 +0000 |
commit | ce12b32c4a502cc5df58f2b46d54370cdf3b673e (patch) | |
tree | d543297e074ed876edeae8cf8c9440a3f2d218a8 /source3/lib | |
parent | 9bcc3886d08c8a506c69c866c7ba4cdfb84a8bdd (diff) | |
download | samba-ce12b32c4a502cc5df58f2b46d54370cdf3b673e.tar.gz samba-ce12b32c4a502cc5df58f2b46d54370cdf3b673e.tar.bz2 samba-ce12b32c4a502cc5df58f2b46d54370cdf3b673e.zip |
Fix compiler warning.
(This used to be commit 3a71b4873034b3fe9dc7b23a95e56c865e857507)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/iconv.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c index c09bff5fd7..e3866c2b53 100644 --- a/source3/lib/iconv.c +++ b/source3/lib/iconv.c @@ -135,17 +135,22 @@ static size_t sys_iconv(void *cd, * enough that Samba works on systems that don't have iconv. **/ size_t smb_iconv(smb_iconv_t cd, - const char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) + const char **inbuffer, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft) { char cvtbuf[2048]; char *bufp = cvtbuf; size_t bufsize; + /* make a copy to ensure inbuffer is const-ed */ + char* inbuf = smb_xstrdup(*inbuffer); + size_t result; /* in many cases we can go direct */ if (cd->direct) { - return cd->direct(cd->cd_direct, - (char **)inbuf, inbytesleft, outbuf, outbytesleft); + result = cd->direct(cd->cd_direct, + &inbuf, inbytesleft, outbuf, outbytesleft); + SAFE_FREE(inbuf); + return result; } @@ -154,18 +159,23 @@ size_t smb_iconv(smb_iconv_t cd, bufp = cvtbuf; bufsize = sizeof(cvtbuf); - if (cd->pull(cd->cd_pull, - (char **)inbuf, inbytesleft, &bufp, &bufsize) == -1 - && errno != E2BIG) return -1; + if (cd->pull(cd->cd_pull, + &inbuf, inbytesleft, &bufp, &bufsize) == -1 && errno != E2BIG) { + SAFE_FREE(inbuf); + return -1; + } bufp = cvtbuf; bufsize = sizeof(cvtbuf) - bufsize; - if (cd->push(cd->cd_push, - &bufp, &bufsize, - outbuf, outbytesleft) == -1) return -1; + if (cd->push(cd->cd_push, + &bufp, &bufsize, outbuf, outbytesleft) == -1) { + SAFE_FREE(inbuf); + return -1; + } } - + + SAFE_FREE(inbuf); return 0; } |