Ver Fonte

avoid out of bounds

johann há 5 anos atrás
pai
commit
390cefc215
1 ficheiros alterados com 2 adições e 0 exclusões
  1. 2 0
      lazpaint/image/uimage.pas

+ 2 - 0
lazpaint/image/uimage.pas

@@ -1998,6 +1998,8 @@ procedure TLazPaintImage.MoveLayer(AFromIndex, AToIndex: integer);
 begin
   if (AFromIndex < 0) or (AFromIndex >= NbLayers) then
     raise exception.Create('Index out of bounds');
+  if AToIndex < 0 then AToIndex := 0;
+  if AToIndex >= NbLayers then AToIndex := NbLayers-1;
   if not CheckNoAction then exit;
   try
     AddUndo(FCurrentState.MoveLayer(AFromIndex,AToIndex));