Fixed Externalize functions to always return allocated buffer, even if source is empty string

This commit is contained in:
Berserker 2019-06-13 00:24:19 +03:00
parent 420ddd7c15
commit 84c569935d

View File

@ -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;
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;
Utils.CopyMem((Length(Str) + 1) * sizeof(WideChar), PWideChar(Str), result);
end;
function MapDir (const VirtPath, RealPath: PWideChar; OverwriteExisting: boolean; Flags: integer = 0): LONGBOOL; stdcall;