aboutsummaryrefslogtreecommitdiffstats
path: root/line-log.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-06-07 08:38:11 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-07 10:30:50 -0700
commit42d2ad55566013535c16b80fc2d445da93cceed3 (patch)
treef44825c4cc18b1ee896a1f04426b2f3e0a9c6205 /line-log.c
parent86badd4d0a51262c2da1ca45c36612a28aad3b59 (diff)
downloadgit-42d2ad55566013535c16b80fc2d445da93cceed3.tar.gz
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>
Diffstat (limited to 'line-log.c')
-rw-r--r--line-log.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/line-log.c b/line-log.c
index 8ff6ccb772..bd3e663c24 100644
--- a/line-log.c
+++ b/line-log.c
@@ -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);
}