summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjavabird25 <shockck84@gmail.com>2022-03-07 14:02:50 +0500
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-03-09 01:05:12 +0330
commit67d10a50ee83384737c2ff51e6a29ee0ce857137 (patch)
tree87404f85c50d9c43075bb39d41d98e900c8b2300
parentce9f355b1233b3f6d858eedc7837a0a2e6994fc1 (diff)
downloadserenity-67d10a50ee83384737c2ff51e6a29ee0ce857137.zip
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.
-rw-r--r--Userland/Applications/Spreadsheet/CellType/Numeric.cpp2
1 files changed, 1 insertions, 1 deletions
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<String> 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;
});