1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-06 22:45:02 +02:00

#6462, not a bug unless you run a version of PHP 5 that is less than 5.0.4...

git-svn-id: file:///svn/phpbb/trunk@6786 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
David M 2006-12-21 04:50:38 +00:00
parent d9f3aed704
commit 2e1eef2713

View File

@ -3568,17 +3568,18 @@ class bitfield
// Get the ($n / 8)th char // Get the ($n / 8)th char
$byte = $n >> 3; $byte = $n >> 3;
if (!isset($this->data[$byte])) if (strlen($this->data) >= $byte + 1)
{
$c = $this->data[$byte];
// Lookup the ($n % 8)th bit of the byte
$bit = 7 - ($n & 7);
return (bool) (ord($c) & (1 << $bit));
}
else
{ {
// Of course, if it doesn't exist then the result if FALSE
return false; return false;
} }
$c = $this->data[$byte];
// Lookup the ($n % 8)th bit of the byte
$bit = 7 - ($n & 7);
return (bool) (ord($c) & (1 << $bit));
} }
function set($n) function set($n)
@ -3586,16 +3587,13 @@ class bitfield
$byte = $n >> 3; $byte = $n >> 3;
$bit = 7 - ($n & 7); $bit = 7 - ($n & 7);
if (isset($this->data[$byte])) if (strlen($this->data) >= $byte + 1)
{ {
$this->data[$byte] = $this->data[$byte] | chr(1 << $bit); $this->data[$byte] = $this->data[$byte] | chr(1 << $bit);
} }
else else
{ {
if ($byte - strlen($this->data) > 0) $this->data .= str_repeat("\0", $byte - strlen($this->data));
{
$this->data .= str_repeat("\0", $byte - strlen($this->data));
}
$this->data .= chr(1 << $bit); $this->data .= chr(1 << $bit);
} }
} }
@ -3604,13 +3602,11 @@ class bitfield
{ {
$byte = $n >> 3; $byte = $n >> 3;
if (!isset($this->data[$byte])) if (strlen($this->data) >= $byte + 1)
{ {
return; $bit = 7 - ($n & 7);
$this->data[$byte] = $this->data[$byte] &~ chr(1 << $bit);
} }
$bit = 7 - ($n & 7);
$this->data[$byte] = $this->data[$byte] &~ chr(1 << $bit);
} }
function get_blob() function get_blob()