]> granicus.if.org Git - apache/commitdiff
Don't segfault if the filter doesn't have any request config prepared.
authorJeff Trawick <trawick@apache.org>
Wed, 25 Oct 2000 16:49:14 +0000 (16:49 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 25 Oct 2000 16:49:14 +0000 (16:49 +0000)
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

index 5d7b5fd1a958b35303a0d0b27cae772ca9604e69..372fd8ac4ce602a145165baddd23039ce909f8a6 100644 (file)
@@ -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;