From 25a06f00714b6a1a4dd9307beae2c3408171b84d Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 26 Jul 2023 21:34:39 -0500 Subject: [PATCH] Math/PrimeField: fix for when garbage collection has wiped data --- phpseclib/Math/PrimeField/Integer.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/phpseclib/Math/PrimeField/Integer.php b/phpseclib/Math/PrimeField/Integer.php index 748f9a49..ddb04912 100644 --- a/phpseclib/Math/PrimeField/Integer.php +++ b/phpseclib/Math/PrimeField/Integer.php @@ -312,8 +312,11 @@ class Integer extends Base */ public function toBytes() { - $length = static::$modulo[$this->instanceID]->getLengthInBytes(); - return str_pad($this->value->toBytes(), $length, "\0", STR_PAD_LEFT); + if (isset(static::$modulo[$this->instanceID])) { + $length = static::$modulo[$this->instanceID]->getLengthInBytes(); + return str_pad($this->value->toBytes(), $length, "\0", STR_PAD_LEFT); + } + return $this->value->toBytes(); } /**