mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 17:49:27 +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);
|
||||
var
|
||||
StartIndex, ToWrite: longint;
|
||||
begin
|
||||
if s='' then
|
||||
exit;
|
||||
if OutCnt+length(s)>=AsmOutSize then
|
||||
AsmFlush;
|
||||
Move(s[1],OutBuf[OutCnt],length(s));
|
||||
inc(OutCnt,length(s));
|
||||
inc(AsmSize,length(s));
|
||||
StartIndex:=1;
|
||||
ToWrite:=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;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user