]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diff.c
diff --color-moved-ws: fix another memory leak
[thirdparty/git.git] / diff.c
diff --git a/diff.c b/diff.c
index 6f122121344b6043fbe3d996777f6766bfaafb9a..e0ebddfac9f024945844a77c971ab9a6596e3fb5 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -811,10 +811,13 @@ static int compute_ws_delta(const struct emitted_diff_symbol *a,
        const struct emitted_diff_symbol *shorter = a->len > b->len ? b : a;
        int d = longer->len - shorter->len;
 
+       if (strncmp(longer->line + d, shorter->line, shorter->len))
+               return 0;
+
        out->string = xmemdupz(longer->line, d);
        out->current_longer = (a == longer);
 
-       return !strncmp(longer->line + d, shorter->line, shorter->len);
+       return 1;
 }
 
 static int cmp_in_block_with_wsd(const struct diff_options *o,
@@ -991,6 +994,8 @@ static void pmb_advance_or_null_multi_match(struct diff_options *o,
                        moved_block_clear(&pmb[i]);
                }
        }
+
+       free(got_match);
 }
 
 static int shrink_potential_moved_blocks(struct moved_block *pmb,