This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new 70193ebf3 ABCGeneratingReducer: handle int/uint switch cases where 
range is so large that it overflows into negative value
70193ebf3 is described below

commit 70193ebf34bb17fbe988543e84db8f7da13a001f
Author: Josh Tynjala <[email protected]>
AuthorDate: Mon Jan 22 09:17:13 2024 -0800

    ABCGeneratingReducer: handle int/uint switch cases where range is so large 
that it overflows into negative value
    
    Fixes unhandled ArrayIndexOutOfBoundsException and 
NegativeArraySizeException
---
 .../royale/compiler/internal/as/codegen/ABCGeneratingReducer.java     | 4 ++++
 1 file changed, 4 insertions(+)

diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGeneratingReducer.java
 
b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGeneratingReducer.java
index 42209b662..e488cfa78 100644
--- 
a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGeneratingReducer.java
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGeneratingReducer.java
@@ -5693,6 +5693,10 @@ public class ABCGeneratingReducer
 
         int range = lookupSwitchInfo.maxCase - lookupSwitchInfo.minCase;
 
+        // range is so large that it overflowed the int
+        if (range < 0)
+            return null;
+
         // if the range is greater than 20 and if less than 50% ranges dense, 
then use if/else
         if ((range > 20) && (range < cases.size() * 2))
             return null;

Reply via email to