mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-09 19:09:56 +02:00
* do not do anything when writing to a t(custom)memorystream if the current
position is negative (patch by Collin Western, mantis #13318) git-svn-id: trunk@12955 -
This commit is contained in:
parent
5cf4ab7642
commit
6f4637b32a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8802,6 +8802,7 @@ tests/webtbs/tw13307.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw1331.pp svneol=native#text/plain
|
tests/webtbs/tw1331.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw13313.pp svneol=native#text/plain
|
tests/webtbs/tw13313.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw13313a.pp svneol=native#text/plain
|
tests/webtbs/tw13313a.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw13318.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw1333.pp svneol=native#text/plain
|
tests/webtbs/tw1333.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw13343.pp svneol=native#text/plain
|
tests/webtbs/tw13343.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw13345x.pp svneol=native#text/plain
|
tests/webtbs/tw13345x.pp svneol=native#text/plain
|
||||||
|
@ -505,7 +505,7 @@ function TCustomMemoryStream.Read(var Buffer; Count: Longint): Longint;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
If (FSize>0) and (FPosition<Fsize) then
|
If (FSize>0) and (FPosition<Fsize) and (FPosition>=0) then
|
||||||
begin
|
begin
|
||||||
Result:=FSize-FPosition;
|
Result:=FSize-FPosition;
|
||||||
If Result>Count then Result:=Count;
|
If Result>Count then Result:=Count;
|
||||||
@ -521,9 +521,13 @@ begin
|
|||||||
Case Origin of
|
Case Origin of
|
||||||
soFromBeginning : FPosition:=Offset;
|
soFromBeginning : FPosition:=Offset;
|
||||||
soFromEnd : FPosition:=FSize+Offset;
|
soFromEnd : FPosition:=FSize+Offset;
|
||||||
soFromCurrent : FpoSition:=FPosition+Offset;
|
soFromCurrent : FPosition:=FPosition+Offset;
|
||||||
end;
|
end;
|
||||||
Result:=FPosition;
|
Result:=FPosition;
|
||||||
|
{$IFDEF DEBUG}
|
||||||
|
if Result < 0 then
|
||||||
|
raise Exception.Create('TCustomMemoryStream');
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -643,7 +647,7 @@ function TMemoryStream.Write(const Buffer; Count: Longint): Longint;
|
|||||||
Var NewPos : Longint;
|
Var NewPos : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Count=0 then
|
If (Count=0) or (FPosition<0) then
|
||||||
exit(0);
|
exit(0);
|
||||||
NewPos:=FPosition+Count;
|
NewPos:=FPosition+Count;
|
||||||
If NewPos>Fsize then
|
If NewPos>Fsize then
|
||||||
|
19
tests/webtbs/tw13318.pp
Normal file
19
tests/webtbs/tw13318.pp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
program fpctest4;
|
||||||
|
{$ifdef fpc}
|
||||||
|
{$mode delphi}
|
||||||
|
{$endif fpc}
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes;
|
||||||
|
|
||||||
|
var
|
||||||
|
f:TStream;
|
||||||
|
l: longint;
|
||||||
|
begin
|
||||||
|
l:=1;
|
||||||
|
f:=TMemoryStream.Create;
|
||||||
|
f.position:=-1;
|
||||||
|
if (f.write(l,4)<>0) then
|
||||||
|
halt(1);
|
||||||
|
f.free;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user