mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-22 13:49:17 +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;
|
function TQueue<T>.DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T;
|
||||||
begin
|
begin
|
||||||
|
if Count = 0 then
|
||||||
|
raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
|
||||||
|
|
||||||
Result := FItems[AIndex];
|
Result := FItems[AIndex];
|
||||||
FItems[AIndex] := Default(T);
|
FItems[AIndex] := Default(T);
|
||||||
Inc(FLow);
|
Inc(FLow);
|
||||||
@ -2151,7 +2154,7 @@ end;
|
|||||||
|
|
||||||
function TStack<T>.DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T;
|
function TStack<T>.DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T;
|
||||||
begin
|
begin
|
||||||
if AIndex < 0 then
|
if (AIndex < 0) or (Count = 0) then
|
||||||
raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
|
raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
|
||||||
|
|
||||||
Result := FItems[AIndex];
|
Result := FItems[AIndex];
|
||||||
|
Loading…
Reference in New Issue
Block a user