File tree Expand file tree Collapse file tree 1 file changed +3
-14
lines changed
Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Original file line number Diff line number Diff line change @@ -68,20 +68,17 @@ protected function __construct(string $bencoded)
6868 */
6969 protected function castInteger (string $ string , bool $ negative ): int
7070 {
71+ $ clamp = PHP_INT_MAX ;
7172 if ($ negative )
7273 {
7374 $ string = "- $ string " ;
7475 $ clamp = PHP_INT_MIN ;
7576 }
76- else
77- {
78- $ clamp = PHP_INT_MAX ;
79- }
8077
8178 $ value = (int ) $ string ;
82- if ($ value === $ clamp )
79+ if ($ value === $ clamp && is_float (+ $ string ) )
8380 {
84- $ this ->checkIntegerOverflow ($ string );
81+ throw new DecodingException ( ' Integer overflow ' , $ this ->offset - 1 - strlen ($ string) );
8582 }
8683
8784 return $ value ;
@@ -116,14 +113,6 @@ protected function checkCursorPosition(): void
116113 }
117114 }
118115
119- protected function checkIntegerOverflow (string $ str ): void
120- {
121- if (is_float (+$ str ))
122- {
123- throw new DecodingException ('Integer overflow ' , $ this ->offset - 1 - strlen ($ str ));
124- }
125- }
126-
127116 protected function complianceError (string $ message , int $ offset ): void
128117 {
129118 throw new ComplianceError ($ message , $ offset );
You can’t perform that action at this time.
0 commit comments