stas 2004/11/12 11:58:10
Modified: src/modules/perl modperl_util.c t/response/TestAPI request_rec.pm . Changes Log: avoid segfaults when a bogus $r object is used Revision Changes Path 1.86 +3 -1 modperl-2.0/src/modules/perl/modperl_util.c Index: modperl_util.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.c,v retrieving revision 1.85 retrieving revision 1.86 diff -u -u -r1.85 -r1.86 --- modperl_util.c 25 Oct 2004 21:57:17 -0000 1.85 +++ modperl_util.c 12 Nov 2004 19:58:10 -0000 1.86 @@ -79,7 +79,9 @@ Perl_croak(aTHX_ "method `%s' invoked by a `%s' object with no `r' key!", cv ? GvNAME(CvGV(cv)) : "unknown", - HvNAME(SvSTASH(SvRV(in)))); + (SvRV(in) && SvSTASH(SvRV(in))) + ? HvNAME(SvSTASH(SvRV(in))) + : "unknown"); } return SvROK(sv) ? SvRV(sv) : sv; 1.32 +26 -1 modperl-2.0/t/response/TestAPI/request_rec.pm Index: request_rec.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestAPI/request_rec.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -u -r1.31 -r1.32 --- request_rec.pm 22 Aug 2004 20:47:37 -0000 1.31 +++ request_rec.pm 12 Nov 2004 19:58:10 -0000 1.32 @@ -23,7 +23,7 @@ sub handler { my $r = shift; - plan $r, tests => 49; + plan $r, tests => 52; #Apache->request($r); #PerlOptions +GlobalRequest takes care my $gr = Apache->request; @@ -177,6 +177,31 @@ ok t_cmp $@, qr/Not an array reference/, '$r->content_languages(invalid)'; } + + ### invalid $r + { + my $r = bless {}, "Apache::RequestRec"; + my $err = q[method `uri' invoked by a `Apache::RequestRec' ] . + q[object with no `r' key!]; + eval { $r->uri }; + ok t_cmp $@, qr/$err/, "invalid $r object"; + } + { + my $r = bless {}, "NonExisting"; + my $err = q[method `uri' invoked by a `NonExisting' ] . + q[object with no `r' key!]; + eval { Apache::RequestRec::uri($r) }; + ok t_cmp $@, qr/$err/, "invalid $r object"; + } + { + my $r = {}; + my $err = q[method `uri' invoked by a `unknown' ] . + q[object with no `r' key!]; + eval { Apache::RequestRec::uri($r) }; + ok t_cmp $@, qr/$err/, "invalid $r object"; + } + + # tested in other tests # - input_filters: TestAPI::in_out_filters # - output_filters: TestAPI::in_out_filters 1.522 +2 -0 modperl-2.0/Changes Index: Changes =================================================================== RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.521 retrieving revision 1.522 diff -u -u -r1.521 -r1.522 --- Changes 9 Nov 2004 05:44:14 -0000 1.521 +++ Changes 12 Nov 2004 19:58:10 -0000 1.522 @@ -12,6 +12,8 @@ =item 1.99_18-dev +avoid segfaults when a bogus $r object is used [Stas] + Remove magicness of PerlLoadModule and implement Apache::Module::add() for modules that implement their own configuration directives [Gozer]