Skip to content

flipdiff: avoid crash on non-commuting patches - #180

Merged
twaugh merged 1 commit into
twaugh:0.4.xfrom
SAY-5:fix-flipdiff-noncommute
Oct 22, 2026
Merged

twaugh merged 1 commit into
twaugh:0.4.xfrom
SAY-5:fix-flipdiff-noncommute

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Pull Request Guidelines

This is a bug fix, so it targets the 0.4.x branch.

Description

flipdiff segfaults when the two patches don't commute, for example on patches produced by git diff. While undoing patch1 from the reconstructed file, remove_line() is asked to remove a line that is no longer present (patch2 already changed it). In that case kill stays NULL and the function dereferences it. This guards the NULL case and returns early, since there is nothing to remove. Fixes #178.

Type of Change

Bug fix (targets 0.4.x)

Testing

Added tests/flip20, which feeds the non-commuting input from the issue to flipdiff and checks it exits successfully instead of crashing.

@ralokt

ralokt commented Jul 14, 2026

Copy link
Copy Markdown

As the reporter, thanks for taking care of this! (disclaimer: didn't test the change myself)

@SAY-5

SAY-5 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Just checking in, this has been green and ready for a while, let me know if anything else is needed before merging.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@twaugh
twaugh force-pushed the fix-flipdiff-noncommute branch from 592dbcf to ad285bd Compare October 22, 2026 14:44
@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.59%. Comparing base (f4a7c5c) to head (ad285bd).

Files with missing lines Patch % Lines
src/interdiff.c 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            0.4.x     #180      +/-   ##
==========================================
- Coverage   83.60%   83.59%   -0.01%     
==========================================
  Files           5        5              
  Lines        4215     4219       +4     
  Branches     1006     1008       +2     
==========================================
+ Hits         3524     3527       +3     
- Misses        691      692       +1     
Flag Coverage Δ
unittests 83.59% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@twaugh
twaugh merged commit 490f515 into twaugh:0.4.x Oct 22, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants