From 7e0d30209a328ee5f5a1742bb3d27e4409abf1d2 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 12 May 2025 15:45:56 +0000 Subject: [PATCH] FpSpreadsheet: Fix range overflow when a cell range is copied in spready to the clipboard. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9741 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/source/common/xlsbiff8.pas | 6 ++++++ components/fpspreadsheet/source/common/xlscommon.pas | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/components/fpspreadsheet/source/common/xlsbiff8.pas b/components/fpspreadsheet/source/common/xlsbiff8.pas index 62bafc795..752c11821 100644 --- a/components/fpspreadsheet/source/common/xlsbiff8.pas +++ b/components/fpspreadsheet/source/common/xlsbiff8.pas @@ -4539,6 +4539,12 @@ var len: Integer; wideStr: WideString; begin + if AString = '' then + begin + Result := 0; + exit; + end; + // string constant is stored as widestring in BIFF8 wideStr := UTF8Decode(AString); len := Length(wideStr); diff --git a/components/fpspreadsheet/source/common/xlscommon.pas b/components/fpspreadsheet/source/common/xlscommon.pas index 8b2c99b5a..4ab3bfe55 100644 --- a/components/fpspreadsheet/source/common/xlscommon.pas +++ b/components/fpspreadsheet/source/common/xlscommon.pas @@ -5724,6 +5724,12 @@ var len: Byte; s: ansistring; begin + if AString = '' then + begin + Result := 0; + exit; + end; + s := ConvertEncoding(AString, encodingUTF8, FCodePage); len := Length(s); AStream.WriteByte(len);