mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Halt NBT parsing if end of data is found
This commit is contained in:
parent
c81a9dc7a6
commit
7f4f6cdf05
1 changed files with 6 additions and 2 deletions
|
|
@ -43,6 +43,10 @@ class NBT{
|
|||
$this->offset += $n;
|
||||
return substr($this->binary, $this->offset - $n, $n);
|
||||
}
|
||||
|
||||
private function feof(){
|
||||
return !isset($this->binary{$this->offset});
|
||||
}
|
||||
|
||||
public function write($bin){
|
||||
$this->binary .= $bin;
|
||||
|
|
@ -119,7 +123,7 @@ class NBT{
|
|||
}
|
||||
|
||||
private function parseList(&$node, $tag, $cnt){
|
||||
for($i = 0; $i < $cnt; ++$i){
|
||||
for($i = 0; $i < $cnt and !$this->feof(); ++$i){
|
||||
switch($tag){
|
||||
case self::TAG_BYTE:
|
||||
$value = $this->readTAG_BYTE();
|
||||
|
|
@ -163,7 +167,7 @@ class NBT{
|
|||
}
|
||||
|
||||
private function parseTree(&$node){
|
||||
while(($tag = ord($this->read(1))) !== self::TAG_END){
|
||||
while(($tag = ord($this->read(1))) !== self::TAG_END and !$this->feof()){
|
||||
$name = $this->readTAG_STRING();
|
||||
switch($tag){
|
||||
case self::TAG_BYTE:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue