From 85d4fed65f3a97bdee202744b4262604c17af3b7 Mon Sep 17 00:00:00 2001 From: Berserker Date: Thu, 13 Jun 2019 00:24:19 +0300 Subject: [PATCH] Fixed Externalize functions to always return allocated buffer, even if source is empty string --- Vfs.dproj | 6 +++++- VfsExport.pas | 16 ++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Vfs.dproj b/Vfs.dproj index e89a8aa..3997d9d 100644 --- a/Vfs.dproj +++ b/Vfs.dproj @@ -30,7 +30,11 @@ Delphi.Personality VCLApplication -FalseTrueFalseTrueTrue1032FalseFalseFalseFalseFalse10491251Alexander Shostak (aka EtherniDee)Virtual File System1.0.3.21.0.0.0Vfs.dpr +FalseTrueFalseTrueTrue1041FalseFalseFalseFalseFalse10491251Alexander Shostak (aka EtherniDee)Virtual File System1.0.4.11.0.0.0Vfs.dpr + + + + diff --git a/VfsExport.pas b/VfsExport.pas index 13cc881..fe09653 100644 --- a/VfsExport.pas +++ b/VfsExport.pas @@ -26,22 +26,14 @@ exports function Externalize (const Str: AnsiString): {O} pointer; overload; begin - result := nil; - - if Str <> '' then begin - GetMem(result, Length(Str) + 1); - Utils.CopyMem(Length(Str) + 1, pointer(Str), result); - end; + GetMem(result, Length(Str) + 1); + Utils.CopyMem(Length(Str) + 1, pchar(Str), result); end; function Externalize (const Str: WideString): {O} pointer; overload; begin - result := nil; - - if Str <> '' then begin - GetMem(result, (Length(Str) + 1) * sizeof(WideChar)); - Utils.CopyMem((Length(Str) + 1) * sizeof(WideChar), pointer(Str), result); - end; + GetMem(result, (Length(Str) + 1) * sizeof(WideChar)); + Utils.CopyMem((Length(Str) + 1) * sizeof(WideChar), PWideChar(Str), result); end; function MapDir (const VirtPath, RealPath: PWideChar; OverwriteExisting: boolean; Flags: integer = 0): LONGBOOL; stdcall;