View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0011720 | mantisbt | attachments | public | 2010-03-28 19:45 | 2010-09-19 03:11 |
Reporter | hallids | Assigned To | dhx | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | duplicate | ||
Product Version | 1.2.0 | ||||
Summary | 0011720: file_download.php running out of memory | ||||
Description | When downloading an attachment, file_download.php is running out of memory, on any size file. Only occurs on files uploaded with earlier version of Mantis. (Not sure which earlier version of Mantis. My previous version was 1.1.4.) The file download completes ok but the file contents is appended with a PHP out-of-memory error, for example Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 524289 bytes) in /var/www/example.com/htdocs/mantisbt-1.2.0/file_download.php on line 209 | ||||
Steps To Reproduce | Open a ticket with a download added in an earlier version of Mantis. You'll need the PHP ini variable 'display_errors' set to be ON. Download the attachment (if it was a text file you will be able to see the appended error message). | ||||
Additional Information | I have fixed this problem in my copy by changing file_download.php line 210 from to It seems like file_get_contents() is returning 0 (zero) instead of boolean false in some cases which is causing an infinite loop. My PHP version is 5.2.5 | ||||
Tags | No tags attached. | ||||
Attached Files | file_download.php.patch (958 bytes)
*** file_download.orig.php 2010-03-29 09:59:29.000000000 +1030 --- file_download.php 2010-03-29 10:51:48.000000000 +1030 *************** *** 207,213 **** @set_time_limit(60*60); //reset time limit to 60 min - should be enough for 1 MB chunk } $buffer = file_get_contents($filename, 0, null, $offset, ( ($maxlength > 0 && $maxlength < $chunksize) ? $maxlength : $chunksize ) ); ! if ( $buffer === false ) { if( $maxlength > 0 ) { $buffer = file_get_contents($filename, 0, null, $offset, $maxlength ); } else { --- 207,213 ---- @set_time_limit(60*60); //reset time limit to 60 min - should be enough for 1 MB chunk } $buffer = file_get_contents($filename, 0, null, $offset, ( ($maxlength > 0 && $maxlength < $chunksize) ? $maxlength : $chunksize ) ); ! if ( !$buffer ) { if( $maxlength > 0 ) { $buffer = file_get_contents($filename, 0, null, $offset, $maxlength ); } else { | ||||