mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 13:08:49 +02:00
* check whether there are any elements at all for both TStack<> and TQueue<> before removing any
git-svn-id: trunk@46843 -
This commit is contained in:
parent
6efd9cc93f
commit
cda338b893
@ -2021,6 +2021,9 @@ end;
|
||||
|
||||
function TQueue<T>.DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T;
|
||||
begin
|
||||
if Count = 0 then
|
||||
raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
|
||||
|
||||
Result := FItems[AIndex];
|
||||
FItems[AIndex] := Default(T);
|
||||
Inc(FLow);
|
||||
@ -2151,7 +2154,7 @@ end;
|
||||
|
||||
function TStack<T>.DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T;
|
||||
begin
|
||||
if AIndex < 0 then
|
||||
if (AIndex < 0) or (Count = 0) then
|
||||
raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
|
||||
|
||||
Result := FItems[AIndex];
|
||||
|
Loading…
Reference in New Issue
Block a user