From 7d82e9d0d14e3a987470011beb2e43f1f2bc3b6f Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Wed, 25 Oct 2000 16:49:14 +0000 Subject: [PATCH] Don't segfault if the filter doesn't have any request config prepared. This can happen when the config doesn't tell us to do anything but the administrator coded us in Add{Input|Output}Filter. Instead of segfaulting, we turn into a noop. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86748 13f79535-47bb-0310-9956-ffa450edef68 --- modules/experimental/mod_charset_lite.c | 36 +++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/modules/experimental/mod_charset_lite.c b/modules/experimental/mod_charset_lite.c index 5d7b5fd1a9..372fd8ac4c 100644 --- a/modules/experimental/mod_charset_lite.c +++ b/modules/experimental/mod_charset_lite.c @@ -801,7 +801,8 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, ap_bucket_brigade *bb) { charset_req_t *reqinfo = ap_get_module_config(f->r->request_config, &charset_lite_module); - charset_dir_t *dc = reqinfo->dc; + charset_dir_t *dc = ap_get_module_config(f->r->per_dir_config, + &charset_lite_module); charset_filter_ctx_t *ctx = f->ctx; ap_bucket *dptr, *consumed_bucket; const char *cur_str; @@ -813,13 +814,16 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, ap_bucket_brigade *bb) if (!ctx) { /* this is AddOutputFilter path; grab the preallocated context, - * if any + * if any; note that if we decided not to do anything in an earlier + * handler, we won't even have a reqinfo */ - ctx = f->ctx = reqinfo->output_ctx; - reqinfo->output_ctx = NULL; /* prevent SNAFU if user coded us twice - * in the filter chain; we can't have two - * instances using the same context - */ + if (reqinfo) { + ctx = f->ctx = reqinfo->output_ctx; + reqinfo->output_ctx = NULL; /* prevent SNAFU if user coded us twice + * in the filter chain; we can't have two + * instances using the same context + */ + } if (!ctx) { /* no idea how to translate; don't do anything */ ctx = f->ctx = apr_pcalloc(f->r->pool, sizeof(charset_filter_ctx_t)); ctx->dc = dc; @@ -971,20 +975,24 @@ static int xlate_in_filter(ap_filter_t *f, ap_bucket_brigade *bb, apr_status_t rv; charset_req_t *reqinfo = ap_get_module_config(f->r->request_config, &charset_lite_module); - charset_dir_t *dc = reqinfo->dc; + charset_dir_t *dc = ap_get_module_config(f->r->per_dir_config, + &charset_lite_module); charset_filter_ctx_t *ctx = f->ctx; apr_size_t buffer_size; int hit_eos; if (!ctx) { /* this is AddInputFilter path; grab the preallocated context, - * if any + * if any; note that if we decided not to do anything in an earlier + * handler, we won't even have a reqinfo */ - ctx = f->ctx = reqinfo->input_ctx; - reqinfo->input_ctx = NULL; /* prevent SNAFU if user coded us twice - * in the filter chain; we can't have two - * instances using the same context - */ + if (reqinfo) { + ctx = f->ctx = reqinfo->input_ctx; + reqinfo->input_ctx = NULL; /* prevent SNAFU if user coded us twice + * in the filter chain; we can't have two + * instances using the same context + */ + } if (!ctx) { /* no idea how to translate; don't do anything */ ctx = f->ctx = apr_pcalloc(f->r->pool, sizeof(charset_filter_ctx_t)); ctx->dc = dc; -- 2.40.0