summaryrefslogtreecommitdiff
path: root/main/SAPI.c
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2016-06-19 17:05:48 +0100
committerJakub Zelenka <bukka@php.net>2016-06-19 17:05:48 +0100
commite63a8540a60e95aa5bd8e269add1b02afcc1b79b (patch)
treeb83a144eec24cc81adab0b9a778f7a730d8df79e /main/SAPI.c
parent7a4cc73641bb3eb878f7184bcbd026ee663cf2a9 (diff)
parent53071e647049f099f7f7a0771ddb63fc2cdd621c (diff)
downloadphp-git-e63a8540a60e95aa5bd8e269add1b02afcc1b79b.tar.gz
Merge branch 'openssl_error_store' into openssl_aead
Diffstat (limited to 'main/SAPI.c')
-rw-r--r--main/SAPI.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index 9781f18c12..496bbfbd12 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -856,15 +856,24 @@ SAPI_API int sapi_send_headers(void)
* in case of an error situation.
*/
if (SG(sapi_headers).send_default_content_type && sapi_module.send_headers) {
- sapi_header_struct default_header;
- uint len;
-
- SG(sapi_headers).mimetype = get_default_content_type(0, &len);
- default_header.header_len = sizeof("Content-type: ") - 1 + len;
- default_header.header = emalloc(default_header.header_len + 1);
- memcpy(default_header.header, "Content-type: ", sizeof("Content-type: ") - 1);
- memcpy(default_header.header + sizeof("Content-type: ") - 1, SG(sapi_headers).mimetype, len + 1);
- sapi_header_add_op(SAPI_HEADER_ADD, &default_header);
+ uint len = 0;
+ char *default_mimetype = get_default_content_type(0, &len);
+
+ if (default_mimetype && len) {
+ sapi_header_struct default_header;
+
+ SG(sapi_headers).mimetype = default_mimetype;
+
+ default_header.header_len = sizeof("Content-type: ") - 1 + len;
+ default_header.header = emalloc(default_header.header_len + 1);
+
+ memcpy(default_header.header, "Content-type: ", sizeof("Content-type: ") - 1);
+ memcpy(default_header.header + sizeof("Content-type: ") - 1, SG(sapi_headers).mimetype, len + 1);
+
+ sapi_header_add_op(SAPI_HEADER_ADD, &default_header);
+ } else {
+ efree(default_mimetype);
+ }
SG(sapi_headers).send_default_content_type = 0;
}