svn commit: samba r26498 - in branches/SAMBA_4_0: .
source/lib/charset source/lib/charset/tests source/param
source/torture
jelmer at samba.org
jelmer at samba.org
Mon Dec 17 08:32:02 GMT 2007
Author: jelmer
Date: 2007-12-17 08:32:00 +0000 (Mon, 17 Dec 2007)
New Revision: 26498
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26498
Log:
Fix memory leak in iconv code.
Modified:
branches/SAMBA_4_0/
branches/SAMBA_4_0/source/lib/charset/charcnv.c
branches/SAMBA_4_0/source/lib/charset/iconv.c
branches/SAMBA_4_0/source/lib/charset/tests/iconv.c
branches/SAMBA_4_0/source/param/loadparm.c
branches/SAMBA_4_0/source/torture/smbiconv.c
Changeset:
Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...
Modified: branches/SAMBA_4_0/source/lib/charset/charcnv.c
===================================================================
--- branches/SAMBA_4_0/source/lib/charset/charcnv.c 2007-12-17 08:20:29 UTC (rev 26497)
+++ branches/SAMBA_4_0/source/lib/charset/charcnv.c 2007-12-17 08:32:00 UTC (rev 26498)
@@ -134,7 +134,8 @@
n1 = charset_name(ic, from);
n2 = charset_name(ic, to);
- ic->conv_handles[from][to] = smb_iconv_open(n2, n1, ic->native_iconv);
+ ic->conv_handles[from][to] = smb_iconv_open_ex(ic, n2, n1,
+ ic->native_iconv);
if (ic->conv_handles[from][to] == (smb_iconv_t)-1) {
if ((from == CH_DOS || to == CH_DOS) &&
@@ -146,8 +147,8 @@
n1 = charset_name(ic, from);
n2 = charset_name(ic, to);
- ic->conv_handles[from][to] = smb_iconv_open(n2, n1,
- ic->native_iconv);
+ ic->conv_handles[from][to] =
+ smb_iconv_open_ex(ic, n2, n1, ic->native_iconv);
}
}
Modified: branches/SAMBA_4_0/source/lib/charset/iconv.c
===================================================================
--- branches/SAMBA_4_0/source/lib/charset/iconv.c 2007-12-17 08:20:29 UTC (rev 26497)
+++ branches/SAMBA_4_0/source/lib/charset/iconv.c 2007-12-17 08:32:00 UTC (rev 26498)
@@ -154,17 +154,17 @@
strcasecmp(name, "UTF-16LE") == 0;
}
-/*
- simple iconv_open() wrapper
- */
-smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode,
- bool native_iconv)
+
+
+smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode,
+ const char *fromcode, bool native_iconv)
{
smb_iconv_t ret;
const struct charset_functions *from=NULL, *to=NULL;
int i;
- ret = (smb_iconv_t)talloc_named(NULL, sizeof(*ret),
+ ret = (smb_iconv_t)talloc_named(mem_ctx,
+ sizeof(*ret),
"iconv(%s,%s)", tocode, fromcode);
if (!ret) {
errno = ENOMEM;
@@ -261,6 +261,14 @@
}
/*
+ simple iconv_open() wrapper
+ */
+smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
+{
+ return smb_iconv_open_ex(NULL, tocode, fromcode, true);
+}
+
+/*
simple iconv_close() wrapper
*/
int smb_iconv_close(smb_iconv_t cd)
Modified: branches/SAMBA_4_0/source/lib/charset/tests/iconv.c
===================================================================
--- branches/SAMBA_4_0/source/lib/charset/tests/iconv.c 2007-12-17 08:20:29 UTC (rev 26497)
+++ branches/SAMBA_4_0/source/lib/charset/tests/iconv.c 2007-12-17 08:32:00 UTC (rev 26498)
@@ -157,8 +157,8 @@
"failed to open %s to UTF-16LE",
charset));
}
- cd2 = smb_iconv_open(charset, "UTF-16LE", lp_parm_bool(test->lp_ctx, NULL, "iconv", "native", true));
- cd3 = smb_iconv_open("UTF-16LE", charset, lp_parm_bool(test->lp_ctx, NULL, "iconv", "native", true));
+ cd2 = smb_iconv_open_ex(test, charset, "UTF-16LE", lp_parm_bool(test->lp_ctx, NULL, "iconv", "native", true));
+ cd3 = smb_iconv_open_ex(test, "UTF-16LE", charset, lp_parm_bool(test->lp_ctx, NULL, "iconv", "native", true));
last_charset = charset;
}
Modified: branches/SAMBA_4_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.c 2007-12-17 08:20:29 UTC (rev 26497)
+++ branches/SAMBA_4_0/source/param/loadparm.c 2007-12-17 08:32:00 UTC (rev 26498)
@@ -2466,7 +2466,7 @@
/* FIXME: Check locale in environment for this: */
if (strcmp(lp_display_charset(lp_ctx), lp_unix_charset(lp_ctx)) != 0)
- d_set_iconv(smb_iconv_open(lp_display_charset(lp_ctx), lp_unix_charset(lp_ctx), true));
+ d_set_iconv(smb_iconv_open(lp_display_charset(lp_ctx), lp_unix_charset(lp_ctx)));
else
d_set_iconv((smb_iconv_t)-1);
Modified: branches/SAMBA_4_0/source/torture/smbiconv.c
===================================================================
--- branches/SAMBA_4_0/source/torture/smbiconv.c 2007-12-17 08:20:29 UTC (rev 26497)
+++ branches/SAMBA_4_0/source/torture/smbiconv.c 2007-12-17 08:32:00 UTC (rev 26498)
@@ -205,7 +205,7 @@
}
}
- cd = smb_iconv_open(to, from, lp_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
+ cd = smb_iconv_open_ex(tctx, to, from, lp_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
if((int)cd == -1) {
DEBUG(0,("unable to find from or to encoding, exiting...\n"));
return 1;
More information about the samba-cvs
mailing list