Skip to content

Commit

Permalink
Fix "dangling pointer" warning
Browse files Browse the repository at this point in the history
Move file_status to the function scope so it doesn't go out of scope while
file_in_head is pointing to the data it contains.
  • Loading branch information
proski authored and koutcher committed Aug 31, 2023
1 parent 06a1b89 commit 46df851
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/stage.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ static bool
find_deleted_line_in_head(struct view *view, struct line *line) {
struct io io;
struct buffer buffer;
struct status file_status;
unsigned long line_number_in_head, line_number = 0;
long bias_by_staged_changes = 0;
char buf[SIZEOF_STR] = "";
Expand All @@ -466,7 +467,6 @@ find_deleted_line_in_head(struct view *view, struct line *line) {
if (buf[0]) {
file_in_head = view->env->file;
} else { // The file might might be renamed in the index. Find its old name.
struct status file_status;
const char *diff_index_argv[] = {
"git", "diff-index", "--cached", "-C",
"--diff-filter=ACR", "-z", "HEAD", NULL
Expand Down

0 comments on commit 46df851

Please sign in to comment.