Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substring length check missing in C# implementation #88

Open
GoogleCodeExporter opened this issue Mar 15, 2015 · 0 comments
Open

Substring length check missing in C# implementation #88

GoogleCodeExporter opened this issue Mar 15, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 27 May 2013 at 1:12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant