httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r644122 - /httpd/httpd/trunk/server/util_expr.c
Date Thu, 03 Apr 2008 00:34:22 GMT
Author: niq
Date: Wed Apr  2 17:34:20 2008
New Revision: 644122

URL: http://svn.apache.org/viewvc?rev=644122&view=rev
Log:
Avoid returning NULL from ap_expr_string.
Empty string works and won't cause segfault.

Modified:
    httpd/httpd/trunk/server/util_expr.c

Modified: httpd/httpd/trunk/server/util_expr.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_expr.c?rev=644122&r1=644121&r2=644122&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_expr.c (original)
+++ httpd/httpd/trunk/server/util_expr.c Wed Apr  2 17:34:20 2008
@@ -897,6 +897,7 @@
 AP_DECLARE(const char*) ap_expr_string(request_rec *r, const char *str)
 {
     /* a default string evaluator: support headers and env */
+    const char *ret = str;
     ap_regmatch_t match[3];
     ap_assert(isvar != NULL);
     if (ap_regexec(isvar, str, 3, match, 0) == 0) {
@@ -915,20 +916,23 @@
         if (table != NULL) {
             char *key = apr_pstrndup(r->pool, str+match[2].rm_so,
                                      match[2].rm_eo-match[2].rm_so);
-            return apr_table_get(table, key);
+            ret = apr_table_get(table, key);
         }
     }
     else if (str[0] == '$') {
         if (!strcasecmp(str, "$handler")) {
-            return r->handler;
+            ret = r->handler;
         }
         else if (!strcasecmp(str, "$content-type")) {
-            return r->content_type;
+            ret = r->content_type;
         }
     }
     /* TODO: provide a hook so modules can interpret other patterns */
     /* OhBugger, where's the regexp for backreferences ? */
-    return str;  /* default - literal string as-is */
+    if (!ret) {
+        ret = "";
+    }
+    return ret;  /* default - literal string as-is */
 }
 static apr_status_t ap_expr_term(void *expr)
 {



Mime
View raw message