Skip to content

Commit 33879ec

Browse files
author
Brian France
committed
Memory assigned to the request_rec should be allocated from apache pools and should not be free'ed at the end of the handler phase
1 parent d087c87 commit 33879ec

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

sapi/apache/mod_php5.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_head
209209
static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
210210
{
211211
request_rec *r = SG(server_context);
212-
char *status_buf = NULL;
213212
const char *sline = SG(sapi_headers).http_status_line;
214213
int sline_len;
215214

@@ -223,21 +222,17 @@ static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
223222
* the status-code: */
224223
if (sline && ((sline_len = strlen(sline)) > 12) && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ' && sline[12] == ' ') {
225224
if ((sline_len - 9) > MAX_STATUS_LENGTH) {
226-
status_buf = estrndup(sline + 9, MAX_STATUS_LENGTH);
225+
r->status_line = ap_pstrndup(r->pool, sline + 9, MAX_STATUS_LENGTH);
227226
} else {
228-
status_buf = estrndup(sline + 9, sline_len - 9);
227+
r->status_line = ap_pstrndup(r->pool, sline + 9, sline_len - 9);
229228
}
230-
r->status_line = status_buf;
231229
}
232230

233231
if(r->status==304) {
234232
send_error_response(r,0);
235233
} else {
236234
send_http_header(r);
237235
}
238-
if (status_buf) {
239-
efree(status_buf);
240-
}
241236
return SAPI_HEADER_SENT_SUCCESSFULLY;
242237
}
243238
/* }}} */

0 commit comments

Comments
 (0)