Fixing bugs found by static analysis

This commit is contained in:
Rasmus Lerdorf
2013-05-07 00:35:10 -07:00
parent 2c967d6023
commit 6f7798b643
27 changed files with 103 additions and 104 deletions

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;

View File

@@ -129,7 +129,7 @@
//----------------------------------------------------------------------
public function getCode()
{
$ret;
$ret = 0;
if($this->count < $this->dataLength) {
$row = $this->count % $this->blocks;

View File

@@ -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)

View File

@@ -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();
}
}
}