mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:26:24 +02:00
* Fixed AV in SysErrorMessage() when there is no message string corresponding to a error code. Bug #13617.
git-svn-id: trunk@13082 -
This commit is contained in:
parent
f59d1b1b0b
commit
57e49c4bb9
@ -604,19 +604,25 @@ var
|
|||||||
MsgBuffer: PWideChar;
|
MsgBuffer: PWideChar;
|
||||||
len: longint;
|
len: longint;
|
||||||
begin
|
begin
|
||||||
|
MsgBuffer:=nil;
|
||||||
len:=FormatMessage(
|
len:=FormatMessage(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM or FORMAT_MESSAGE_IGNORE_INSERTS,
|
FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM or FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
nil,
|
nil,
|
||||||
ErrorCode,
|
ErrorCode,
|
||||||
0,
|
0,
|
||||||
PWideChar(@MsgBuffer), { This function allocs the memory (in this case you pass a PPwidechar)}
|
@MsgBuffer, { This function allocs the memory (in this case you pass a PPwidechar)}
|
||||||
0,
|
0,
|
||||||
nil);
|
nil);
|
||||||
while (len > 0) and (MsgBuffer[len - 1] <= #32) do
|
|
||||||
Dec(len);
|
if MsgBuffer <> nil then begin
|
||||||
MsgBuffer[len]:=#0;
|
while (len > 0) and (MsgBuffer[len - 1] <= #32) do
|
||||||
PWideCharToString(PWideChar(MsgBuffer), Result);
|
Dec(len);
|
||||||
LocalFree(HLOCAL(MsgBuffer));
|
MsgBuffer[len]:=#0;
|
||||||
|
PWideCharToString(MsgBuffer, Result);
|
||||||
|
LocalFree(HLOCAL(MsgBuffer));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user