]> granicus.if.org Git - php/commitdiff
MFB:
authorBrian France <bfrance@php.net>
Thu, 12 Oct 2006 20:13:07 +0000 (20:13 +0000)
committerBrian France <bfrance@php.net>
Thu, 12 Oct 2006 20:13:07 +0000 (20:13 +0000)
  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

sapi/apache/mod_php5.c

index f0f7ba8ce8635263f1dcf05a71fe7b11b9cc6979..459cd26fbb404bee3871ceb8e2b582952b2547fb 100644 (file)
@@ -205,7 +205,6 @@ static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_head
 static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
 {
        request_rec *r = SG(server_context);
-       char *status_buf = NULL;
        const char *sline = SG(sapi_headers).http_status_line;
        int sline_len;
 
@@ -219,11 +218,10 @@ static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
         * the status-code: */
        if (sline && ((sline_len = strlen(sline)) > 12) && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ' && sline[12] == ' ') {
                if ((sline_len - 9) > MAX_STATUS_LENGTH) {
-                       status_buf = estrndup(sline + 9, MAX_STATUS_LENGTH);
+                       r->status_line = ap_pstrndup(r->pool, sline + 9, MAX_STATUS_LENGTH);
                } else {
-                       status_buf = estrndup(sline + 9, sline_len - 9);
+                       r->status_line = ap_pstrndup(r->pool, sline + 9, sline_len - 9);
                }
-               r->status_line = status_buf;
        }
 
        if(r->status==304) {
@@ -231,9 +229,6 @@ static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
        } else {
                send_http_header(r);
        }
-       if (status_buf) {
-               efree(status_buf);
-       }
        return SAPI_HEADER_SENT_SUCCESSFULLY;
 }
 /* }}} */