diff-match-patch-c
diff-match-patch-c copied to clipboard
Prepare a PR for https://github.com/arrbee/diff-match-patch-c/issues/5
OK, Here is a fix for the problem :-)
The problem was caused by the first loop in diff_cleanup_merge(). 'i' was used as the position for the current element, and updated to node->next at the end of each loop iteration. HOWEVER, some of the loop iterations have unallocated the current node pointed by 'i', effectively setting its 'next' element to point to the free store, thereby corrupting 'i'. The solution was to calculate the next 'i' and saving it at the beginning of the loop iteration.
Thanks!