New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segfault in POSIX module #6952
Comments
From despair@cpan.orgThis is a bug report for perl from despair@cpan.org, When calling isdigit(undef) function from POSIX.pm we get segfault. Flags: Site configuration information for perl v5.8.0: Configured by bhcompile at Tue Feb 18 22:17:47 EST 2003. Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Locally applied patches: @INC for perl v5.8.0: Environment for perl v5.8.0: |
From @rgsSADAHIRO Tomoyuki wrote:
I actually added a test for POSIX::isalnum('') and POSIX::isalnum(undef)
The SvPV (actually, SvPV_nolen) actually occurs, via the typemap.
Thanks for pointing this out. |
From @rgsRafael Garcia-Suarez wrote:
Did I actually wrote three times actually in the same mail ? Yes. |
From BQW10602@nifty.comOn Sat, 29 Nov 2003 14:00:55 +0100
Well, I don't know whether isalpha() should be equivalent to I think another non-string like a reference is better to be treated SADAHIRO Tomoyuki |
From BQW10602@nifty.comisxxx.patchdiff -urN perl-5.8.2/ext/POSIX/POSIX.xs perl-new/ext/POSIX/POSIX.xs
--- perl-5.8.2/ext/POSIX/POSIX.xs Wed Oct 01 02:10:22 2003
+++ perl-new/ext/POSIX/POSIX.xs Sat Nov 29 22:12:42 2003
@@ -842,10 +842,12 @@
int
isalnum(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!isalnum(*s))
RETVAL = 0;
@@ -854,10 +856,12 @@
int
isalpha(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!isalpha(*s))
RETVAL = 0;
@@ -866,10 +870,12 @@
int
iscntrl(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!iscntrl(*s))
RETVAL = 0;
@@ -878,10 +884,12 @@
int
isdigit(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!isdigit(*s))
RETVAL = 0;
@@ -890,10 +898,12 @@
int
isgraph(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!isgraph(*s))
RETVAL = 0;
@@ -902,10 +912,12 @@
int
islower(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!islower(*s))
RETVAL = 0;
@@ -914,10 +926,12 @@
int
isprint(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!isprint(*s))
RETVAL = 0;
@@ -926,10 +940,12 @@
int
ispunct(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!ispunct(*s))
RETVAL = 0;
@@ -938,10 +954,12 @@
int
isspace(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!isspace(*s))
RETVAL = 0;
@@ -950,10 +968,12 @@
int
isupper(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!isupper(*s))
RETVAL = 0;
@@ -962,10 +982,12 @@
int
isxdigit(charstring)
- unsigned char * charstring
+ SV * charstring
+ PREINIT:
+ STRLEN len;
CODE:
- unsigned char *s = charstring;
- unsigned char *e = s + SvCUR(ST(0));
+ unsigned char *s = (unsigned char *) SvPV(charstring, len);
+ unsigned char *e = s + len;
for (RETVAL = 1; RETVAL && s < e; s++)
if (!isxdigit(*s))
RETVAL = 0;
diff -urN perl-5.8.2/ext/POSIX/t/is.t perl-new/ext/POSIX/t/is.t
--- perl-5.8.2/ext/POSIX/t/is.t Wed Oct 01 02:10:22 2003
+++ perl-new/ext/POSIX/t/is.t Sat Nov 29 23:00:56 2003
@@ -52,6 +52,10 @@
" \t" => [ qw(space) ],
"abcde\001" => [],
+
+ # An empty string. Always true (al least in old days) [bug #24554]
+ '' => [ qw(print graph alnum alpha lower upper digit xdigit
+ punct cntrl space) ],
);
|
@rspier - Status changed from 'new' to 'resolved' |
From @rgsSADAHIRO Tomoyuki wrote:
Thanks, applied as #21823.
I added also a test for the stringification of references |
Migrated from rt.perl.org#24554 (status was 'resolved')
Searchable as RT24554$
The text was updated successfully, but these errors were encountered: