From 67d10a50ee83384737c2ff51e6a29ee0ce857137 Mon Sep 17 00:00:00 2001 From: javabird25 Date: Mon, 7 Mar 2022 14:02:50 +0500 Subject: [PATCH] Spreadsheet: Fix overridden max length related crash NumericCell::display() attempted to take a substring of cell contents according to the "Override max length" parameter, but it did not account for the actual string length. --- Userland/Applications/Spreadsheet/CellType/Numeric.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp index 3a6ad0871c..0b41cb2453 100644 --- a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp @@ -28,7 +28,7 @@ JS::ThrowCompletionOr NumericCell::display(Cell& cell, const CellTypeMet string = format_double(metadata.format.characters(), TRY(value.to_double(cell.sheet().global_object()))); if (metadata.length >= 0) - return string.substring(0, metadata.length); + return string.substring(0, min(string.length(), metadata.length)); return string; });