On Mon Oct 19 21:50:54 2015, joenio wrote:
Show quoted text
Adding tests does not fix the problem
SVupgradetounistr () calls SvCUR () on an SvIV which returns junk (a very large number)
This is perl 5, version 14, subversion 2 (v5.14.2) built for IA64.ARCHREV_0-LP64-ld
.cpan/build/Unicode-LineBreak-2015.11-46_Fzg $ make test
:
t/10gcstring.t ........... 1/37 SVupgradetounistr: Not enough space at /home/merijn/.cpan/build/Unicode-LineBreak-2015.11-46_Fzg/blib/lib/Unicode/GCString.pm line 46.
# Looks like you planned 37 tests but ran 35.
# Looks like your test exited with 12 just after 35.
t/10gcstring.t ........... Dubious, test returned 12 (wstat 3072, 0xc00)
Failed 2/37 subtests
.cpan/build/Unicode-LineBreak-2015.11-46_Fzg $ perl -Mblib -MUnicode::GCString -wE'$_=Unicode::GCString->new (5)'
SVupgradetounistr: Not enough space at /home/merijn/.cpan/build/Unicode-LineBreak-2015.11-46_Fzg/blib/lib/Unicode/GCString.pm line 46.
At line 121, str is
SV = IV(0x60000000000724d8) at 0x60000000000724e8
REFCNT = 1
FLAGS = (IOK,READONLY,pIOK)
IV = 5
NO PV!
The code should add
if (!SvOK(str))
return buf;
if (!SvPOK(str))
sv_upgrade(str, SVt_PVIV);
But that makes the test fail. It is up to the maintainer to decide what steps to take from here
The full code as I tested:
--8<---
static
unistr_t *SVupgradetounistr(unistr_t *buf, SV *str)
{
char *s;
size_t len, i;
if (buf == NULL) {
if ((buf = malloc(sizeof(unistr_t))) == NULL)
croak("SVupgradetounistr: %s", strerror(errno));
} else if (buf->str)
free(buf->str);
buf->str = NULL;
buf->len = 0;
if (!SvOK(str))
return buf;
if (!SvPOK(str))
sv_upgrade(str, SVt_PVIV);
len = SvCUR(str);
if (len == 0)
return buf;
if ((buf->str = malloc(sizeof(unichar_t) * len)) == NULL)
croak("SVupgradetounistr: %s", strerror(errno));
s = SvPV(str, len);
for (i = 0; i < len; i++)
buf->str[i] = (unichar_t)(unsigned char)s[i];
buf->len = len;
return buf;
}
-->8---