Skip to content
Browse files

Avoid modifying pass-by-reference string in stream.php.

  • Loading branch information...
1 parent 49e6ac3 commit 8c929db256417d12be245dee7b92cfd4bcfa286f @aaronschmitz committed Apr 25, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 libraries/joomla/filesystem/stream.php
View
5 libraries/joomla/filesystem/stream.php
@@ -773,12 +773,13 @@ public function write(&$string, $length = 0, $chunk = 0)
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$remaining = $length;
+ $start = 0;
do
{
// If the amount remaining is greater than the chunk size, then use the chunk
$amount = ($remaining > $chunk) ? $chunk : $remaining;
- $res = fwrite($this->_fh, $string, $amount);
+ $res = fwrite($this->_fh, substr($string, $start), $amount);
// Returns false on error or the number of bytes written
if ($res === false)
@@ -797,7 +798,7 @@ public function write(&$string, $length = 0, $chunk = 0)
else
{
// Wrote something
- $string = substr($string, $amount);
+ $start += $amount;
$remaining -= $res;
}
}

0 comments on commit 8c929db

Please sign in to comment.
Something went wrong with that request. Please try again.