Skip to content

DiffLine mangled memory #1135

Closed
Closed
@FintanH

Description

@FintanH

I've come across a strange issue where the use of a DiffLine in two different locations ends up with some mangled looking output. I've created a reproducible in this repository https://github.com/FintanH/git2-diff-memory. If you cargo run you should see the following output:

PRINT FROM INSIDE find_lines
- h2 {
+ .event {
    margin-bottom: 1rem;
  }
- .event {
+ h2 {
    margin-bottom: 1rem;
+   padding: 1px;
  }
  hr {
    margin: 1rem 0;
PRINT FROM OUTSIDE find_lines
�H��U  >�r��Sn-bottom: 1rem;
  }
- .event {
+ h2 {
    margin-bottom: 1rem;
+   padding: 1px;
  }
  hr {
    margin: 1rem 0;

Afaict, the outputs should be equal – the range of lines is not different so it should not be selecting other data. My best guess is that the raw pointer within the DiffLine is getting corrupted somehow by returning it within the Vec.

Let me know if I can provide anymore info to help 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions