php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch temporary.patch for Apache2 related Bug #64047

Patch version 2013-01-22 14:01 UTC

Return to Bug #64047 | Download this patch
Patch Revisions:

Developer: remi@php.net

diff -up php-5.3.3/sapi/apache2handler/sapi_apache2.c.orig php-5.3.3/sapi/apache2handler/sapi_apache2.c
--- php-5.3.3/sapi/apache2handler/sapi_apache2.c.orig	2013-01-15 09:53:36.791800213 +0100
+++ php-5.3.3/sapi/apache2handler/sapi_apache2.c	2013-01-15 10:13:53.361063989 +0100
@@ -79,11 +79,15 @@ php_apache_sapi_ub_write(const char *str
 	php_struct *ctx;
 
 	ctx = SG(server_context);
+	if (ctx == NULL) {
+		ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, "PHP no server_context (ub_write)");
+	} else {
 	r = ctx->r;
 
 	if (ap_rwrite(str, str_length, r) < 0) {
 		php_handle_aborted_connection();
 	}
+	}
 
 	return str_length; /* we always consume all the data passed to us. */
 }
@@ -95,6 +99,11 @@ php_apache_sapi_header_handler(sapi_head
 	char *val, *ptr;
 
 	ctx = SG(server_context);
+	if (ctx == NULL) {
+		ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, "PHP no server_context (header_handler)");
+		/* could occurs in request shudown and http error 500 */
+		return 0;
+	}
 
 	switch (op) {
 		case SAPI_HEADER_DELETE:
@@ -156,6 +165,10 @@ php_apache_sapi_send_headers(sapi_header
 	php_struct *ctx = SG(server_context);
 	const char *sline = SG(sapi_headers).http_status_line;
 
+	if (ctx == NULL) {
+		ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL, "PHP no server_context (send_header)");
+		return SAPI_HEADER_SEND_FAILED;
+	}
 	ctx->r->status = SG(sapi_headers).http_response_code;
 
 	/* httpd requires that r->status_line is set to the first digit of
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 09:01:32 2024 UTC