1
0
mirror of https://github.com/git/git synced 2024-06-30 22:54:27 +00:00

line-log: stop assigning string constant to file parent buffer

Stop assigning a string constant to the file parent buffer and instead
assign an allocated string. While the code is fine in practice, it will
break once we compile with `-Wwrite-strings`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt 2024-06-07 08:38:11 +02:00 committed by Junio C Hamano
parent 86badd4d0a
commit 42d2ad5556

View File

@ -1032,6 +1032,7 @@ static int process_diff_filepair(struct rev_info *rev,
struct range_set tmp;
struct diff_ranges diff;
mmfile_t file_parent, file_target;
char *parent_data_to_free = NULL;
assert(pair->two->path);
while (rg) {
@ -1056,7 +1057,7 @@ static int process_diff_filepair(struct rev_info *rev,
file_parent.ptr = pair->one->data;
file_parent.size = pair->one->size;
} else {
file_parent.ptr = "";
file_parent.ptr = parent_data_to_free = xstrdup("");
file_parent.size = 0;
}
@ -1075,6 +1076,7 @@ static int process_diff_filepair(struct rev_info *rev,
diff_ranges_release(&diff);
free(parent_data_to_free);
return ((*diff_out)->parent.nr > 0);
}