Skip to content

Commit

Permalink
pdf: some TPdfWrite internal refactoring
Browse files Browse the repository at this point in the history
- no functional change, made code cleaner to avoid any potential buffer overflow
  • Loading branch information
Arnaud Bouchez committed Jan 16, 2025
1 parent baef721 commit 1189d7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'2.3.9404'
'2.3.9405'
6 changes: 3 additions & 3 deletions src/ui/mormot.ui.pdf.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4871,14 +4871,14 @@ function TPdfWrite.AddEscapeText(Text: PAnsiChar; Font: TPdfFont): TPdfWrite;

function TPdfWrite.AddHex(const Bin: PdfString): TPdfWrite;
var
L, len: integer;
L, len: PtrInt;
PW: pointer;
begin
len := length(Bin);
PW := pointer(Bin);
repeat
L := len;
if BEnd - B <= L * 2 then
if PtrInt(BEnd - B) <= L * 2 then // note: PtrInt(BEnd - B) could be < 0
begin
Save;
if L > high(fTmp) shr 1 then
Expand Down Expand Up @@ -5039,7 +5039,7 @@ function TPdfWrite.AddUnicodeHex(PW: PWideChar; WideCharCount: integer): TPdfWri
end;

var
L: integer;
L: PtrInt;
{$ifdef USE_PDFSECURITY}
sectmp: TSynTempBuffer;
{$endif USE_PDFSECURITY}
Expand Down

0 comments on commit 1189d7e

Please sign in to comment.