Backport of:

From c164ca7383d5f204915d85a5826655d3f1557148 Mon Sep 17 00:00:00 2001
From: Jim Jagielski <jim@apache.org>
Date: Fri, 26 Sep 2014 11:00:14 +0000
Subject: [PATCH] Merge r1624234 from trunk:

SECURITY (CVE-2014-3581): Fix a mod_cache NULL pointer deference
in Content-Type handling.

mod_cache: Avoid a crash when Content-Type has an empty value. PR56924.

Submitted By: Mark Montague <mark catseye.org>
Reviewed By: Jan Kaluza

Submitted by: jkaluza
Reviewed/backported by: jim


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1627749 13f79535-47bb-0310-9956-ffa450edef68
---
 CHANGES                    | 4 ++++
 STATUS                     | 5 -----
 modules/cache/cache_util.c | 6 ++++--
 3 files changed, 8 insertions(+), 7 deletions(-)

Index: apache2-2.4.7/modules/cache/cache_util.c
===================================================================
--- apache2-2.4.7.orig/modules/cache/cache_util.c	2015-03-05 12:36:22.668840232 -0500
+++ apache2-2.4.7/modules/cache/cache_util.c	2015-03-05 12:37:06.393173138 -0500
@@ -1251,8 +1251,10 @@
 
     if (!apr_table_get(headers_out, "Content-Type")
         && r->content_type) {
-        apr_table_setn(headers_out, "Content-Type",
-                       ap_make_content_type(r, r->content_type));
+        const char *ctype = ap_make_content_type(r, r->content_type);
+        if (ctype) {
+            apr_table_setn(headers_out, "Content-Type", ctype);
+        }
     }
 
     if (!apr_table_get(headers_out, "Content-Encoding")
