diff options
author | Tim Potter <tpot@samba.org> | 2003-07-14 01:18:43 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2003-07-14 01:18:43 +0000 |
commit | 4b25a466242bf009a7b97df795cf2e5d6a249da5 (patch) | |
tree | 4c24a2cf96e91b52e7c597a9fa12289c298983a5 | |
parent | 5345a5d7217bb343e032a73334058e6f296ff3cc (diff) | |
download | samba-4b25a466242bf009a7b97df795cf2e5d6a249da5.tar.gz samba-4b25a466242bf009a7b97df795cf2e5d6a249da5.tar.bz2 samba-4b25a466242bf009a7b97df795cf2e5d6a249da5.zip |
Undo 'Fix compiler warning'. It didn't work because the value of inbuf changes so
we end up freeing a pointer we didn't mallocate.
Also, calling strdup() in a frequently called function just to clear up a
const compiler warning seems inelegant and inefficient.
(This used to be commit a0da5ae1198082d0cf18707ed2cf05f728b00d0b)
-rw-r--r-- | source3/lib/iconv.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c index e3866c2b53..c09bff5fd7 100644 --- a/source3/lib/iconv.c +++ b/source3/lib/iconv.c @@ -135,22 +135,17 @@ 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 **inbuffer, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) + const char **inbuf, 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) { - result = cd->direct(cd->cd_direct, - &inbuf, inbytesleft, outbuf, outbytesleft); - SAFE_FREE(inbuf); - return result; + return cd->direct(cd->cd_direct, + (char **)inbuf, inbytesleft, outbuf, outbytesleft); } @@ -159,23 +154,18 @@ size_t smb_iconv(smb_iconv_t cd, bufp = cvtbuf; bufsize = sizeof(cvtbuf); - if (cd->pull(cd->cd_pull, - &inbuf, inbytesleft, &bufp, &bufsize) == -1 && errno != E2BIG) { - SAFE_FREE(inbuf); - return -1; - } + if (cd->pull(cd->cd_pull, + (char **)inbuf, inbytesleft, &bufp, &bufsize) == -1 + && errno != E2BIG) return -1; bufp = cvtbuf; bufsize = sizeof(cvtbuf) - bufsize; - if (cd->push(cd->cd_push, - &bufp, &bufsize, outbuf, outbytesleft) == -1) { - SAFE_FREE(inbuf); - return -1; - } + if (cd->push(cd->cd_push, + &bufp, &bufsize, + outbuf, outbytesleft) == -1) return -1; } - - SAFE_FREE(inbuf); + return 0; } |