From 6f7798b6434f5ef6073447998c436901b507e3df Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Tue, 7 May 2013 00:35:10 -0700 Subject: Fixing bugs found by static analysis --- lib/MiniTemplator.class.php | 4 ++-- lib/phpqrcode/bindings/tcpdf/qrcode.php | 8 ++++---- lib/phpqrcode/phpqrcode.php | 12 ++++++------ lib/phpqrcode/qrencode.php | 2 +- lib/phpqrcode/qrmask.php | 4 ++-- lib/phpqrcode/qrsplit.php | 8 ++++---- 6 files changed, 19 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/MiniTemplator.class.php b/lib/MiniTemplator.class.php index 69281cb5e..a139473f9 100644 --- a/lib/MiniTemplator.class.php +++ b/lib/MiniTemplator.class.php @@ -336,7 +336,7 @@ function processBeginBlockCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) { $this->openBlocksTab[$this->currentNestingLevel] = $blockNo; $this->currentNestingLevel += 1; if ($this->currentNestingLevel > $this->maxNestingLevel) { - $trhis->triggerError ("Block nesting overflow in template at offset $cmdTPosBegin."); + $this->triggerError ("Block nesting overflow in template at offset $cmdTPosBegin."); return false; } return true; } @@ -844,7 +844,7 @@ function readFileIntoString ($fileName, &$s) { $fh = fopen($fileName,"rb"); if ($fh === false) return false; $fileSize = filesize($fileName); - if ($fileSize === false) {close ($fh); return false; } + if ($fileSize === false) {fclose ($fh); return false; } $s = fread($fh,$fileSize); fclose ($fh); if (strlen($s) != $fileSize) return false; diff --git a/lib/phpqrcode/bindings/tcpdf/qrcode.php b/lib/phpqrcode/bindings/tcpdf/qrcode.php index 7995460b5..9001e3a2e 100644 --- a/lib/phpqrcode/bindings/tcpdf/qrcode.php +++ b/lib/phpqrcode/bindings/tcpdf/qrcode.php @@ -1101,7 +1101,7 @@ if (!class_exists('QRcode', false)) { protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) { $b = 0; $bitMask = array(); - $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); + $bitMask = $this->generateMaskNo($maskNo, $width, $s); if ($maskGenOnly) { return; } @@ -1399,7 +1399,7 @@ if (!class_exists('QRcode', false)) { $p += 2; } $this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr)); - return $run; + return $p; } /** @@ -1470,7 +1470,7 @@ if (!class_exists('QRcode', false)) { break; } case QR_MODE_KJ: { - if ($hint == QR_MODE_KJ) { + if ($this->hint == QR_MODE_KJ) { $length = $this->eatKanji(); } else { $length = $this->eat8(); @@ -1499,7 +1499,7 @@ if (!class_exists('QRcode', false)) { $stringLen = strlen($this->dataStr); $p = 0; while ($p < $stringLen) { - $mode = $this->identifyMode(substr($this->dataStr, $p), $this->hint); + $mode = $this->identifyMode(substr($this->dataStr, $p)); if ($mode == QR_MODE_KJ) { $p += 2; } else { diff --git a/lib/phpqrcode/phpqrcode.php b/lib/phpqrcode/phpqrcode.php index 80adb9df2..02b877639 100644 --- a/lib/phpqrcode/phpqrcode.php +++ b/lib/phpqrcode/phpqrcode.php @@ -2195,7 +2195,7 @@ case QR_MODE_NUM: $length = $this->eatNum(); break; case QR_MODE_AN: $length = $this->eatAn(); break; case QR_MODE_KANJI: - if ($hint == QR_MODE_KANJI) + if ($this->modeHint == QR_MODE_KANJI) $length = $this->eatKanji(); else $length = $this->eat8(); break; @@ -2217,7 +2217,7 @@ $p = 0; while ($p<$stringLen) { - $mode = self::identifyMode(substr($this->dataStr, $p), $this->modeHint); + $mode = self::identifyMode(substr($this->dataStr, $p)); if($mode == QR_MODE_KANJI) { $p += 2; } else { @@ -2621,13 +2621,13 @@ if (file_exists($fileName)) { $bitMask = self::unserial(file_get_contents($fileName)); } else { - $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); + $bitMask = $this->generateMaskNo($maskNo, $width, $s); if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) mkdir(QR_CACHE_DIR.'mask_'.$maskNo); file_put_contents($fileName, self::serial($bitMask)); } } else { - $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); + $bitMask = $this->generateMaskNo($maskNo, $width, $s); } if ($maskGenOnly) @@ -2937,7 +2937,7 @@ //---------------------------------------------------------------------- public function getCode() { - $ret; + $ret = 0; if($this->count < $this->dataLength) { $row = $this->count % $this->blocks; @@ -3059,7 +3059,7 @@ $input = new QRinput($version, $level); if($input == NULL) return NULL; - $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string)); + $ret = $input->append(QR_MODE_8, strlen($string), str_split($string)); if($ret < 0) { unset($input); return NULL; diff --git a/lib/phpqrcode/qrencode.php b/lib/phpqrcode/qrencode.php index 4b77a5bdd..5bdeaec20 100644 --- a/lib/phpqrcode/qrencode.php +++ b/lib/phpqrcode/qrencode.php @@ -129,7 +129,7 @@ //---------------------------------------------------------------------- public function getCode() { - $ret; + $ret = 0; if($this->count < $this->dataLength) { $row = $this->count % $this->blocks; diff --git a/lib/phpqrcode/qrmask.php b/lib/phpqrcode/qrmask.php index b14d7ae16..43d653ce3 100644 --- a/lib/phpqrcode/qrmask.php +++ b/lib/phpqrcode/qrmask.php @@ -149,13 +149,13 @@ if (file_exists($fileName)) { $bitMask = self::unserial(file_get_contents($fileName)); } else { - $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); + $bitMask = $this->generateMaskNo($maskNo, $width, $s); if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) mkdir(QR_CACHE_DIR.'mask_'.$maskNo); file_put_contents($fileName, self::serial($bitMask)); } } else { - $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); + $bitMask = $this->generateMaskNo($maskNo, $width, $s); } if ($maskGenOnly) diff --git a/lib/phpqrcode/qrsplit.php b/lib/phpqrcode/qrsplit.php index d75b82737..1f9f65c3b 100644 --- a/lib/phpqrcode/qrsplit.php +++ b/lib/phpqrcode/qrsplit.php @@ -186,7 +186,7 @@ if($ret < 0) return -1; - return $run; + return $ret; } //---------------------------------------------------------------------- @@ -258,7 +258,7 @@ case QR_MODE_NUM: $length = $this->eatNum(); break; case QR_MODE_AN: $length = $this->eatAn(); break; case QR_MODE_KANJI: - if ($hint == QR_MODE_KANJI) + if ($this->modeHint == QR_MODE_KANJI) $length = $this->eatKanji(); else $length = $this->eat8(); break; @@ -280,7 +280,7 @@ $p = 0; while ($p<$stringLen) { - $mode = self::identifyMode(substr($this->dataStr, $p), $this->modeHint); + $mode = self::identifyMode(substr($this->dataStr, $p)); if($mode == QR_MODE_KANJI) { $p += 2; } else { @@ -308,4 +308,4 @@ return $split->splitString(); } - } \ No newline at end of file + } -- cgit v1.2.3