Skip to content

Commit 1e7f069

Browse files
committed
Fix
1 parent 0271b9c commit 1e7f069

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

src/Kernel/Mnemonics/_invokespecial.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ public function execute(): void
2828
$invokerClass = $this->popFromOperandStack();
2929

3030

31-
$arguments = array_fill(0, $parsedSignature['arguments_count'] - 1, null);
32-
for ($i = $parsedSignature['arguments_count'] - 1; $i >= 0; $i--) {
33-
$arguments[$i] = $this->popFromOperandStack();
31+
$arguments = [];
32+
if (($length = $parsedSignature['arguments_count'] - 1) >= 0) {
33+
$arguments = array_fill(0, $length, null);
34+
for ($i = $length; $i >= 0; $i--) {
35+
$arguments[$i] = $this->popFromOperandStack();
36+
}
3437
}
3538

3639
$methodName = $cpInfo[$nameAndTypeIndex->getNameIndex()]->getString();

src/Kernel/Mnemonics/_invokestatic.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ public function execute(): void
3030
[$resourceType, $classObject] = $this->getOptions('class_resolver')
3131
->resolve($cpInfo[$cpInfo[$cp->getClassIndex()]->getClassIndex()]->getString());
3232

33-
$arguments = array_fill(0, $signature['arguments_count'] - 1, null);
34-
for ($i = $signature['arguments_count'] - 1; $i >= 0; $i--) {
35-
$arguments[$i] = $this->popFromOperandStack();
33+
$arguments = [];
34+
if (($length = $signature['arguments_count'] - 1) >= 0) {
35+
$arguments = array_fill(0, $length, null);
36+
for ($i = $length; $i >= 0; $i--) {
37+
$arguments[$i] = $this->popFromOperandStack();
38+
}
3639
}
3740

3841
$return = null;

src/Kernel/Mnemonics/_invokevirtual.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ public function execute(): void
2929
// signature
3030
$signature = Formatter::parseSignature($cpInfo[$nameAndTypeIndex->getDescriptorIndex()]->getString());
3131

32-
$arguments = array_fill(0, $signature['arguments_count'] - 1, null);
33-
for ($i = $signature['arguments_count'] - 1; $i >= 0; $i--) {
34-
$arguments[$i] = $this->popFromOperandStack();
32+
$arguments = [];
33+
if (($length = $signature['arguments_count'] - 1) >= 0) {
34+
$arguments = array_fill(0, $length, null);
35+
for ($i = $length; $i >= 0; $i--) {
36+
$arguments[$i] = $this->popFromOperandStack();
37+
}
3538
}
3639

3740
$invokerClass = $this->popFromOperandStack();

0 commit comments

Comments
 (0)