Fixes range check errors patch by Martin Friebe.

git-svn-id: trunk@15184 -
This commit is contained in:
sekelsenmat 2008-05-19 21:49:46 +00:00
parent b86b98e34d
commit fe83d3ce23
3 changed files with 11 additions and 9 deletions

View File

@ -1278,7 +1278,8 @@ begin
begin
TextLen := Windows.GetWindowTextLengthW(AHandle);
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);
Result := Utf8Encode(WideBuffer);
end
@ -1286,7 +1287,8 @@ begin
begin
TextLen := Windows.GetWindowTextLength(AHandle);
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);
Result := AnsiToUtf8(AnsiBuffer);
end;

View File

@ -625,9 +625,9 @@ function TWin32WidgetSet.ClipboardGetOwnerShip(ClipboardType: TClipboardType;
if FormatID=Windows.CF_UNICODETEXT then
begin
SetLength(BufferString, DataStream.Size);
DataStream.Read(BufferString[1], DataStream.Size);
DataStream.Read(PChar(BufferString)^, DataStream.Size);
BufferWideString := Utf8Decode(BufferString);
BufferStream.Write(BufferWideString[1], Length(BufferString) * 2);
BufferStream.Write(PChar(BufferWideString)^, Length(BufferString) * 2);
BufferStream.Position := 0;
WriteStreamToClipBoard(FormatID, BufferStream);
@ -1080,7 +1080,7 @@ begin
else
begin
SetLength(s, count);
if count > 0 then move(str^, s[1], count);
move(str^, PChar(s)^, count);
end;
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
if UnicodeEnabledOS then
@ -1247,7 +1247,7 @@ begin
else
begin
SetLength(s, count);
if count > 0 then move(str^, s[1], count);
move(str^, PChar(s)^, count);
end;
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
if UnicodeEnabledOS
@ -1842,7 +1842,7 @@ begin
else
begin
SetLength(s, count);
move(str^, s[1], count);
move(str^, PChar(s)^, count);
end;
// the length of utf8 vs Wide/Ansi the strings differ, so recalc.
if UnicodeEnabledOS then

View File

@ -164,7 +164,7 @@ var
begin
AnsiChars:= Utf8ToAnsi(s);
Result := GetMem(length(AnsiChars)+1);
Move(AnsiChars[1], Result^, length(AnsiChars)+1);
Move(PChar(AnsiChars)^, Result^, length(AnsiChars)+1);
end;
{------------------------------------------------------------------------------
@ -467,7 +467,7 @@ begin
else
FileNameBufferSize := Length(FileNameWide);
Move(FileNameWide[1], FileNameWideBuffer^, FileNameBufferSize * 2);
Move(PChar(FileNameWide)^, FileNameWideBuffer^, FileNameBufferSize * 2);
end
else begin
FileNameBuffer := AllocMem(FileNameBufferLen + 1);