
torsten.foertsch at gmx
Feb 18, 2008, 1:00 PM
Post #1 of 7
(2398 views)
Permalink
|
Hi, modperl_config_dir_create begins with these lines: void *modperl_config_dir_create(apr_pool_t *p, char *dir) { modperl_config_dir_t *dcfg = modperl_config_dir_new(p); dcfg->location = dir; While dcfg is created anew the dir pointer is simply stored. This means the lifetime of dcfg may exceed the lifetime of the dir pointer. In fact I have found the bug because I got rubbish from $r->location in the response phase after the response handler was added via $r->add_config in the map2storage phase. Here is a patch and a test case. Torsten Index: src/modules/perl/modperl_config.c =================================================================== --- src/modules/perl/modperl_config.c (revision 35) +++ src/modules/perl/modperl_config.c (working copy) @@ -20,7 +20,7 @@ { modperl_config_dir_t *dcfg = modperl_config_dir_new(p); - dcfg->location = dir; + dcfg->location = dir ? apr_pstrdup(p, dir) : NULL; MP_TRACE_d(MP_FUNC, "dir %s", dir); Index: t/response/TestAPI/add_config.pm =================================================================== --- t/response/TestAPI/add_config.pm (revision 31) +++ t/response/TestAPI/add_config.pm (working copy) @@ -59,6 +59,14 @@ }; $r->pnotes(followsymlinks => "$@"); + eval { + my $path="/a/path/to/somewhere"; + $r->add_config(['PerlResponseHandler '.__PACKAGE__], -1, $path); + # now overwrite the path in place to see if the location pointer + # is really copied: see modperl_config_dir_create + $path=~tr[a-z][n-za-m]; + }; + return Apache2::Const::DECLINED; } @@ -83,7 +91,7 @@ my ($self, $r) = @_; my $cf = $self->get_config($r->server); - plan $r, tests => 8; + plan $r, tests => 9; ok t_cmp $r->pnotes('add_config1'), qr/.+\n/; ok t_cmp $r->pnotes('add_config2'), (APACHE22 ? qr/.+\n/ : ''); @@ -103,6 +111,8 @@ my $opts = APACHE22 ? Apache2::Const::OPT_SYM_LINKS : $expect; ok t_cmp $r->allow_override_opts, $opts; + ok t_cmp $r->location, '/a/path/to/somewhere'; + return Apache2::Const::OK; } @@ -118,7 +128,6 @@ <Directory @DocumentRoot@> AllowOverride All </Directory> - PerlResponseHandler TestAPI::add_config PerlMapToStorageHandler TestAPI::add_config::map2storage PerlFixupHandler TestAPI::add_config::fixup </VirtualHost> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe [at] perl For additional commands, e-mail: dev-help [at] perl
|