Fixed #2148 AS2 Uninitialized class fields detector

This commit is contained in:
Jindra Petřík
2023-12-10 22:38:29 +01:00
parent ea6618599f
commit 3f0fab913e
2 changed files with 22 additions and 17 deletions

View File

@@ -77,6 +77,7 @@ All notable changes to this project will be documented in this file.
- [#2145] FLA Export - missing frames, cliping layers order, nullpointer, empty sound layers
- [#2142] XML Export - string values containing only spaces
- AS3 - Nullpointer in MethodBody when no ABC set
- [#2148] AS2 Uninitialized class fields detector
### Changed
- [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class
@@ -3355,6 +3356,7 @@ Major version of SWF to XML export changed to 2.
[#2139]: https://www.free-decompiler.com/flash/issues/2139
[#2145]: https://www.free-decompiler.com/flash/issues/2145
[#2142]: https://www.free-decompiler.com/flash/issues/2142
[#2148]: https://www.free-decompiler.com/flash/issues/2148
[#2120]: https://www.free-decompiler.com/flash/issues/2120
[#1130]: https://www.free-decompiler.com/flash/issues/1130
[#1220]: https://www.free-decompiler.com/flash/issues/1220

View File

@@ -313,24 +313,27 @@ public class UninitializedClassFieldsDetector {
AbstractGraphTargetVisitor visitor = new AbstractGraphTargetVisitor() {
@Override
public void visit(GraphTargetItem item) {
if (item instanceof SetMemberActionItem) {
if (item instanceof SetMemberActionItem) {
List<String> path = getFullPath(item);
if (path != null) {
List<String> parent = new ArrayList<>(path);
parent.remove(parent.size() - 1);
String name = path.get(path.size() - 1);
if ((item instanceof SetMemberActionItem)
|| (item instanceof CallMethodActionItem)
|| (item instanceof NewMethodActionItem)
|| (item instanceof DeleteActionItem)
|| (item instanceof GetMemberActionItem)
) {
List<String> path = getFullPath(item);
if (path != null) {
List<String> parent = new ArrayList<>(path);
parent.remove(parent.size() - 1);
String name = path.get(path.size() - 1);
String className = String.join(".", parent);
if (classInheritance.containsKey(className)) {
//it's a class
if (!containsTrait(classTraits, classInheritance, className, name) && (!result.containsKey(className) || !result.get(className).containsKey(name))) {
Variable v = new Variable(true, name, null, className);
if (!result.containsKey(className)) {
result.put(className, new LinkedHashMap<>());
}
result.get(className).put(name, v);
}
String className = String.join(".", parent);
if (classInheritance.containsKey(className)) {
//it's a class
if (!containsTrait(classTraits, classInheritance, className, name) && (!result.containsKey(className) || !result.get(className).containsKey(name))) {
if (!result.containsKey(className)) {
result.put(className, new LinkedHashMap<>());
}
Variable v = new Variable(true, name, null, className);
result.get(className).put(name, v);
}
}
}