From 08b02ae83cc6d567e220d32694961e2bd309b3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 27 Jan 2018 20:43:42 +0100 Subject: [PATCH] ActionRandomNumber fixed for nonpositive numbers --- CHANGELOG.md | 1 + .../flash/action/model/RandomNumberActionItem.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92469add4..1450b5f9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. - Better AS2 class detection - AS1/2 break statement decompilation in for..in loops - AS2 direct editation - not generating Pop in class header ifs +- AS1/2 deobfuscation - ActionRandom fixed for nonpositive numbers ## [11.0.0] - 2018-01-17 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java index fd0c7aa28..15c4261cc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -41,7 +42,11 @@ public class RandomNumberActionItem extends ActionItem { } public static Integer getResult(Object maximum) { - return rnd.nextInt(EcmaScript.toInt32(maximum)); + int maximumInt = EcmaScript.toInt32(maximum); + if (maximumInt <= 0) { + return 0; + } + return rnd.nextInt(maximumInt); } @Override