From 820799e19345e558b9d0051f0357f277b60284fa Mon Sep 17 00:00:00 2001 From: Zi Ree Date: Wed, 22 Jun 2022 03:20:54 +0200 Subject: [PATCH] FIRE-31718 - truncate preprocessed lsl script text in case of an error to prevent the viewer from stalling while trying to fit a massive blob of text into the script editor --- indra/newview/fslslpreproc.cpp | 16 ++++++++++++++++ indra/newview/skins/default/xui/en/strings.xml | 1 + 2 files changed, 17 insertions(+) diff --git a/indra/newview/fslslpreproc.cpp b/indra/newview/fslslpreproc.cpp index b2e815df0a..12f46fa2eb 100644 --- a/indra/newview/fslslpreproc.cpp +++ b/indra/newview/fslslpreproc.cpp @@ -1540,6 +1540,22 @@ void FSLSLPreprocessor::start_process() } } } + else + { + // FIRE-31718: Preprocessor crashes viewer on recursive #include + + // Truncate the resulting preprocessed script to something the text field can handle without + // freezing for so long the viewer disconnects. The usual script source code limit is 64kB so + // let's play it safe and allow twice as much here. The script is most likely already unusable + // at this point due to the preprocessor bailing out with an error earlier, so a truncated + // version doesn't hurt more than it already did. + if (output.size() > 128 * 1024) + { + output.resize(128 * 1024); + display_error(LLTrans::getString("fs_preprocessor_truncated")); + } + } + if (!errored) { if (preprocessor_enabled && use_compression) diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 722bc66f90..4ecb7e2744 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3153,6 +3153,7 @@ Your current position: [AVATAR_POS] Caching completed for '[FILENAME]' Error: script named '[FILENAME]' isn't safe to copy to the filesystem. This include will fail. Error caching included file '[FILENAME]' + Warning: Preprocessor output truncated due to excessive script text size. This script will most likely not work.