On Mon, 11 Aug 2008 19:01:09 +0100 (BST), John-Mark Bell wrote:
> Well the only way for that to return NULL would be encountering
> UTF8_CONVERT_NOMEM or for the input parameters to be bad (namely item and
> charset being NULL). Given the gdb output above, it's clearly the charset
> conversion that's causing problems. I've still insufficient details to
> know why, though.
Some further investigation, and it appears that this is where it is
returning UTF8_CONVERT_NOMEM:
utf8.c line 304 /* no match, so create a new cd */
cd = iconv_open(to, from);
if (cd == (iconv_t)-1) {
if (errno == EINVAL)
return UTF8_CONVERT_BADENC;
/* default to no memory */
>>>>>>> return UTF8_CONVERT_NOMEM; <<<<<<<<
I can't get the actual value of errno though.
(gdb) p errno
No symbol "errno" in current context.
Below is some of the output from gdb.
item and charset are certainly there at the start of the function:
Breakpoint 1, form_encode_item (item=0x647b4720 "aaaa",
charset=0x64780770 "ISO-8859-1", fallback=0x64e4e630 "ISO-8859-1")
at render/form.c:700
700 char *ret = NULL;
706 snprintf(cset, sizeof cset, "%s//TRANSLIT", charset);
(gdb) p item
$7 = 0x647b4720 "aaaa"
(gdb) p charset
$8 = 0x64780770 "ISO-8859-1"
(gdb) p err
$9 = UTF8_CONVERT_OK
(gdb) p ret
$10 = 0x0
(gdb) p cset
$11 = (random gibberish - obviously uninitialised)
Hitting next again brings up the NoMemory error, which suggests this
line might be the culprit:
err = utf8_to_enc(item, cset, 0, &ret);
Breakpoint 1, utf8_to_enc (string=0x67b70720 "abc123",
encname=0x696bf630 "ISO-8859-1//TRANSLIT", len=0, result=0x696bf62c)
at utils/utf8.c:246
246 return utf8_convert(string, len, "UTF-8", encname, result);
Breakpoint 1, utf8_convert (string=0x67b7c720 "abcdefgh", len=0,
from=0x6a3e5e1c "UTF-8", to=0x696d7630 "ISO-8859-1//TRANSLIT",
result=0x696d762c) at utils/utf8.c:281
281 assert(string && from && to && result);
283 if (strcasecmp(from, to) == 0) {
(gdb) p from
$1 = 0x6a3e5e1c "UTF-8"
(gdb) p to
$2 = 0x696d7630 "ISO-8859-1//TRANSLIT"