mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 23:39:40 +02:00
Fixes range check errors patch by Martin Friebe.
git-svn-id: trunk@15184 -
This commit is contained in:
parent
b86b98e34d
commit
fe83d3ce23
@ -1278,7 +1278,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
TextLen := Windows.GetWindowTextLengthW(AHandle);
|
TextLen := Windows.GetWindowTextLengthW(AHandle);
|
||||||
SetLength(WideBuffer, TextLen);
|
SetLength(WideBuffer, TextLen);
|
||||||
TextLen := Windows.GetWindowTextW(AHandle, @WideBuffer[1], TextLen + 1);
|
If TextLen > 0 // Never give Windows the chance to write to System.emptychar
|
||||||
|
Then TextLen := Windows.GetWindowTextW(AHandle, PWideChar(WideBuffer), TextLen + 1);
|
||||||
SetLength(WideBuffer, TextLen);
|
SetLength(WideBuffer, TextLen);
|
||||||
Result := Utf8Encode(WideBuffer);
|
Result := Utf8Encode(WideBuffer);
|
||||||
end
|
end
|
||||||
@ -1286,7 +1287,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
TextLen := Windows.GetWindowTextLength(AHandle);
|
TextLen := Windows.GetWindowTextLength(AHandle);
|
||||||
SetLength(AnsiBuffer, TextLen);
|
SetLength(AnsiBuffer, TextLen);
|
||||||
TextLen := Windows.GetWindowText(AHandle, @AnsiBuffer[1], TextLen + 1);
|
If TextLen > 0 // Never give Windows the chance to write to System.emptychar
|
||||||
|
Then TextLen := Windows.GetWindowText(AHandle, PChar(AnsiBuffer), TextLen + 1);
|
||||||
SetLength(AnsiBuffer, TextLen);
|
SetLength(AnsiBuffer, TextLen);
|
||||||
Result := AnsiToUtf8(AnsiBuffer);
|
Result := AnsiToUtf8(AnsiBuffer);
|
||||||
end;
|
end;
|
||||||
|
@ -625,9 +625,9 @@ function TWin32WidgetSet.ClipboardGetOwnerShip(ClipboardType: TClipboardType;
|
|||||||
if FormatID=Windows.CF_UNICODETEXT then
|
if FormatID=Windows.CF_UNICODETEXT then
|
||||||
begin
|
begin
|
||||||
SetLength(BufferString, DataStream.Size);
|
SetLength(BufferString, DataStream.Size);
|
||||||
DataStream.Read(BufferString[1], DataStream.Size);
|
DataStream.Read(PChar(BufferString)^, DataStream.Size);
|
||||||
BufferWideString := Utf8Decode(BufferString);
|
BufferWideString := Utf8Decode(BufferString);
|
||||||
BufferStream.Write(BufferWideString[1], Length(BufferString) * 2);
|
BufferStream.Write(PChar(BufferWideString)^, Length(BufferString) * 2);
|
||||||
BufferStream.Position := 0;
|
BufferStream.Position := 0;
|
||||||
|
|
||||||
WriteStreamToClipBoard(FormatID, BufferStream);
|
WriteStreamToClipBoard(FormatID, BufferStream);
|
||||||
@ -1080,7 +1080,7 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
SetLength(s, count);
|
SetLength(s, count);
|
||||||
if count > 0 then move(str^, s[1], count);
|
move(str^, PChar(s)^, count);
|
||||||
end;
|
end;
|
||||||
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
|
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
|
||||||
if UnicodeEnabledOS then
|
if UnicodeEnabledOS then
|
||||||
@ -1247,7 +1247,7 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
SetLength(s, count);
|
SetLength(s, count);
|
||||||
if count > 0 then move(str^, s[1], count);
|
move(str^, PChar(s)^, count);
|
||||||
end;
|
end;
|
||||||
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
|
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
|
||||||
if UnicodeEnabledOS
|
if UnicodeEnabledOS
|
||||||
@ -1842,7 +1842,7 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
SetLength(s, count);
|
SetLength(s, count);
|
||||||
move(str^, s[1], count);
|
move(str^, PChar(s)^, count);
|
||||||
end;
|
end;
|
||||||
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
|
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
|
||||||
if UnicodeEnabledOS then
|
if UnicodeEnabledOS then
|
||||||
|
@ -164,7 +164,7 @@ var
|
|||||||
begin
|
begin
|
||||||
AnsiChars:= Utf8ToAnsi(s);
|
AnsiChars:= Utf8ToAnsi(s);
|
||||||
Result := GetMem(length(AnsiChars)+1);
|
Result := GetMem(length(AnsiChars)+1);
|
||||||
Move(AnsiChars[1], Result^, length(AnsiChars)+1);
|
Move(PChar(AnsiChars)^, Result^, length(AnsiChars)+1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -467,7 +467,7 @@ begin
|
|||||||
else
|
else
|
||||||
FileNameBufferSize := Length(FileNameWide);
|
FileNameBufferSize := Length(FileNameWide);
|
||||||
|
|
||||||
Move(FileNameWide[1], FileNameWideBuffer^, FileNameBufferSize * 2);
|
Move(PChar(FileNameWide)^, FileNameWideBuffer^, FileNameBufferSize * 2);
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
FileNameBuffer := AllocMem(FileNameBufferLen + 1);
|
FileNameBuffer := AllocMem(FileNameBufferLen + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user