From d303036e82276e64224a471923d2e68394ac5b4d Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 1 Feb 2016 17:26:19 +0300 Subject: [PATCH] EA-78555 - assert: Block. accept invalid ranges as initial Block - throw exception for computed ones only --- platform/vcs-impl/src/com/intellij/diff/Block.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/diff/Block.java b/platform/vcs-impl/src/com/intellij/diff/Block.java index 5a5f747f0200..8ccacb7ba103 100644 --- a/platform/vcs-impl/src/com/intellij/diff/Block.java +++ b/platform/vcs-impl/src/com/intellij/diff/Block.java @@ -39,13 +39,9 @@ public class Block { } public Block(@NotNull String[] source, int start, int end) { - if (start < 0 || end > source.length || end < start) { - LOG.error("Invalid block range: [" + start + ", " + end + "); length - " + source.length); - } - mySource = source; - myStart = start; - myEnd = end; + myStart = Math.min(Math.max(0, start), source.length); + myEnd = Math.min(Math.max(myStart, end), source.length); } @NotNull @@ -80,6 +76,10 @@ public class Block { if (start == -1) start = myStart - shift; if (end == -1) end = myEnd - shift; + if (start < 0 || end > prevContent.length || end < start) { + LOG.error("Invalid block range: [" + start + ", " + end + "); length - " + prevContent.length); + } + return new Block(prevContent, start, end); }