From 2e1eef2713f7891ce9d78736ceae6d2faf93fc4b Mon Sep 17 00:00:00 2001 From: David M Date: Thu, 21 Dec 2006 04:50:38 +0000 Subject: [PATCH] #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 --- phpBB/includes/functions.php | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 04113fae06..ea05d969a2 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3568,17 +3568,18 @@ class bitfield // Get the ($n / 8)th char $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; } - - $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) @@ -3586,16 +3587,13 @@ class bitfield $byte = $n >> 3; $bit = 7 - ($n & 7); - if (isset($this->data[$byte])) + if (strlen($this->data) >= $byte + 1) { $this->data[$byte] = $this->data[$byte] | chr(1 << $bit); } 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); } } @@ -3604,13 +3602,11 @@ class bitfield { $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()