curran / curran/google-diff-match-patch
Substring length check missing in C# implementation
- Dominant language
- Python
- Stars
- 17
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
```
There's an issue with the diff_CleanupMerge function around line 1280. It
attempts to do a .Substring with the start index being outside the range of the
string.
I changed the following line:
} else if (diffs[pointer].text.StartsWith(diffs[pointer + 1].text,
StringComparison.Ordinal)) {
to:
} else if (diffs[pointer].text.StartsWith(diffs[pointer + 1].text,
StringComparison.Ordinal) &&
diffs[pointer + 1].text.Length < diffs[pointer].text.Length) {
to prevent this call from happening:
diffs[pointer].text =
diffs[pointer].text.Substring(diffs[pointer + 1].text.Length)
+ diffs[pointer + 1].text;
Now for all I know, the change I've made could invalidate the patch (I don't
really understand what I'm changing, but I needed to get rid of the exception
that was being thrown at all costs), but I'm guessing based on comments and
that it seems to have a "changes = true;" line in there that it's just doing
some optimizations on patch size and failing.
```
Original issue reported on code.google.com by `jrho...@redpointsoftware.com.au` on 27 May 2013 at 1:12
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.