git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/1] Exit on invalid diff status of diff_filepair

From
Jake Roggenbuck <jakeroggenbuck2@gmail.com>
Date
Jan 8, 2025, 06:01 UTC
Message-ID
<20250108060151.7218-1-jakeroggenbuck2@gmail.com>
In-Reply-To
<CAEUC8gmgq_yViedLGHOeSyvR9rQK+O-8Fh9wzds=2+326ngUjw@mail.gmail.com>
Hi all,

Git showed that object files were empty, so I manually removed them. After removing a few object files, I ran `git diff` and I got a segfault.

I have since narrowed down the source of the error to a usage of `diff_filepair`. I also noticed that the `status` field of `diff_filepair` does not get set and stays a zero value. My fix is to check for that invalid status character and exit gracefully with an error message.

I modeled the behavior of this patch after what `git log` does in the same situation. `git log` will exit with a message that reads `bad object HEAD`.

I initially found this segfault when using git while working on a school assignment. I am really interested in helping fix this segfault. I'd be happy to hear any feedback.

Thank you!
Jake Roggenbuck (1):
  Exit on invalid diff status of diff_filepair
 diff.c | 4 ++++
 1 file changed, 4 insertions(+)
-- 
2.47.0
Previous: jake roggenbuckNext: Jake Roggenbuck
Message 2 of 7 in “bug: Segfault with git diff”
  1. jake roggenbuckMay 19, 2024
  2. 0/1 Exit on invalid diff status of diff_filepairJake Roggenbuck, Jan 8, 2025
  3. 1/1 Exit on invalid diff status of diff_filepairJake Roggenbuck, Jan 8, 2025
  4. Jake RoggenbuckApr 30, 2025
  5. Jake RoggenbuckApr 30, 2025
  6. Eric SunshineMay 1, 2025
  7. Junio C HamanoMay 1, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.