mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 13:49:39 +02:00
* fixed buffer overrun in TExternalAssembler.AsmWrite(ansistring) in case the
ansistring's length is > AsmOutSize git-svn-id: branches/jvmbackend@19637 -
This commit is contained in:
parent
c42e4178c5
commit
38c090c1a2
@ -480,14 +480,27 @@ Implementation
|
|||||||
|
|
||||||
|
|
||||||
Procedure TExternalAssembler.AsmWrite(const s:ansistring);
|
Procedure TExternalAssembler.AsmWrite(const s:ansistring);
|
||||||
|
var
|
||||||
|
StartIndex, ToWrite: longint;
|
||||||
begin
|
begin
|
||||||
if s='' then
|
if s='' then
|
||||||
exit;
|
exit;
|
||||||
if OutCnt+length(s)>=AsmOutSize then
|
if OutCnt+length(s)>=AsmOutSize then
|
||||||
AsmFlush;
|
AsmFlush;
|
||||||
Move(s[1],OutBuf[OutCnt],length(s));
|
StartIndex:=1;
|
||||||
inc(OutCnt,length(s));
|
ToWrite:=length(s);
|
||||||
inc(AsmSize,length(s));
|
while ToWrite>AsmOutSize do
|
||||||
|
begin
|
||||||
|
Move(s[StartIndex],OutBuf[OutCnt],AsmOutSize);
|
||||||
|
inc(OutCnt,AsmOutSize);
|
||||||
|
inc(AsmSize,AsmOutSize);
|
||||||
|
AsmFlush;
|
||||||
|
inc(StartIndex,AsmOutSize);
|
||||||
|
dec(ToWrite,AsmOutSize);
|
||||||
|
end;
|
||||||
|
Move(s[StartIndex],OutBuf[OutCnt],ToWrite);
|
||||||
|
inc(OutCnt,ToWrite);
|
||||||
|
inc(AsmSize,ToWrite);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user