diff options
author | Christian Aistleitner <christian@quelltextlich.at> | 2013-05-17 23:30:28 +0200 |
---|---|---|
committer | Christian Aistleitner <christian@quelltextlich.at> | 2013-05-18 11:03:40 +0200 |
commit | 490fa71cc798c87e0d0aaace754584c6d702cd83 (patch) | |
tree | 478a0e48c893b7a526dd33a237c625ba991836e6 /gerrit-httpd | |
parent | 0979925a47ea17b812e57f5e1d5bbac854fef486 (diff) |
Fix PatchScript's mapping of lines below the last edit
For comments below the last edit block of a PatchScript, the formulae
to obtain the line number shifts between sides subtracted one side's
end, but added the other side's beginning (instead of also the
end). This mismatch could cause the client to fetch lines beyond a
file's end and thereby cause an ArrayIndexofBoundException.
We now use the difference of the last edit block's ends to map lines
below the last edit.
Change-Id: I67d2baa0f5ede3af7348c609034de81e8acf9c17
Diffstat (limited to 'gerrit-httpd')
-rw-r--r-- | gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java index 5019403db0..9a4b89f6f3 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptBuilder.java @@ -346,7 +346,7 @@ class PatchScriptBuilder { } final Edit last = edits.get(edits.size() - 1); - return last.getBeginB() + (a - last.getEndA()); + return last.getEndB() + (a - last.getEndA()); } private int mapB2A(final int b) { @@ -372,7 +372,7 @@ class PatchScriptBuilder { } final Edit last = edits.get(edits.size() - 1); - return last.getBeginA() + (b - last.getEndB()); + return last.getEndA() + (b - last.getEndB()); } private void packContent(boolean ignoredWhitespace) { |