ソースを参照

avoid out of bounds

johann 5 年 前
コミット
390cefc215
1 ファイル変更2 行追加0 行削除
  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));