diff --git a/CHANGELOG.md b/CHANGELOG.md
index 311e15f2b..81e52a7a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,9 @@ All notable changes to this project will be documented in this file.
- [#1955] AS3 - Exception during removing trait
- [#688] AS3 Direct editation - construction (new keyword) converted to call when result not used
+### Changed
+- [#1957] Increased maximum stack size to avoid StackOverflowErrors on unusual scripts
+
## [18.3.3] - 2023-01-22
### Added
- [#1913] Option to retain shape exact position(bounds) in SVG export
@@ -2936,6 +2939,7 @@ All notable changes to this project will be documented in this file.
[#1940]: https://www.free-decompiler.com/flash/issues/1940
[#1955]: https://www.free-decompiler.com/flash/issues/1955
[#688]: https://www.free-decompiler.com/flash/issues/688
+[#1957]: https://www.free-decompiler.com/flash/issues/1957
[#1913]: https://www.free-decompiler.com/flash/issues/1913
[#1894]: https://www.free-decompiler.com/flash/issues/1894
[#1801]: https://www.free-decompiler.com/flash/issues/1801
diff --git a/build.properties b/build.properties
index 1cb1c3946..e984a6e99 100644
--- a/build.properties
+++ b/build.properties
@@ -19,6 +19,7 @@ mac.category.type = public.app-category.developer-tools
max.heap.size.percent = 100
#for run task (MB):
max.heap.size.run = 8094
+max.stack.size = 32
exe.icon = graphics/icon_ffdec_round2.ico
locales.dir = src/com/jpexs/decompiler/flash/gui/locales
diff --git a/build.xml b/build.xml
index 914ab9159..1a47bb865 100644
--- a/build.xml
+++ b/build.xml
@@ -420,6 +420,7 @@
preferJre
64/32
${max.heap.size.percent}
+ -Xss${max.stack.size}m
-Djava.net.preferIPv4Stack=true
-Djna.nosys=true
@@ -695,6 +696,7 @@
+
diff --git a/resources/ffdec.bat b/resources/ffdec.bat
index a6d49634c..116bc3750 100644
--- a/resources/ffdec.bat
+++ b/resources/ffdec.bat
@@ -3,7 +3,10 @@ rem Set following to higher value if you want more memory:
rem You need 64 bit OS and 64 bit java to set it to higher values
set MEMORY=1024m
+rem Set following to higher value when you encounter StackOverFlowErrors
+set STACK_SIZE=32m
+
rem Hide VLC error output
set VLC_VERBOSE=-1
-java -Xmx%MEMORY% -Djna.nosys=true -jar "%~dp0\ffdec.jar" %*
\ No newline at end of file
+java -Xmx%MEMORY% -Xss%STACK_SIZE% -Djna.nosys=true -jar "%~dp0\ffdec.jar" %*
\ No newline at end of file
diff --git a/resources/ffdec.sh b/resources/ffdec.sh
index 64d6229b7..165f39bd8 100644
--- a/resources/ffdec.sh
+++ b/resources/ffdec.sh
@@ -4,6 +4,9 @@
# You need 64 bit OS and 64 bit java to set it to higher values
MEMORY=1024m
+# Set following to higher value when you encounter StackOverFlowErrors
+STACK_SIZE=32m
+
# Hide VLC error output
export VLC_VERBOSE=-1
@@ -74,7 +77,7 @@ fi
popd > /dev/null
-args=(-Djava.net.preferIPv4Stack=true -Xmx$MEMORY -jar $JAR_FILE "$@")
+args=(-Djava.net.preferIPv4Stack=true -Xmx$MEMORY -Xss$STACK_SIZE -jar $JAR_FILE "$@")
if [ "`uname`" = "Darwin" ]; then
args=(-Xdock:name=FFDec -Xdock:icon=icon.png "${args[@]}")