Skip to content

Commit 9ccd0a8

Browse files
bdowninggitster
authored andcommitted
Always initialize xpparam_t to 0
We're going to be adding some parameters to this, so we can't have any uninitialized data in it. Signed-off-by: Brian Downing <bdowning@lavos.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7c4ed8c commit 9ccd0a8

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

builtin-blame.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
523523
xdemitconf_t xecfg;
524524
xdemitcb_t ecb;
525525

526+
memset(&xpp, 0, sizeof(xpp));
526527
xpp.flags = xdl_opts;
527528
memset(&xecfg, 0, sizeof(xecfg));
528529
xecfg.ctxlen = context;

builtin-rerere.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static int diff_two(const char *file1, const char *label1,
9898

9999
printf("--- a/%s\n+++ b/%s\n", label1, label2);
100100
fflush(stdout);
101+
memset(&xpp, 0, sizeof(xpp));
101102
xpp.flags = XDF_NEED_MINIMAL;
102103
memset(&xecfg, 0, sizeof(xecfg));
103104
xecfg.ctxlen = 3;

combine-diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ static void combine_diff(const unsigned char *parent, mmfile_t *result_file,
213213

214214
parent_file.ptr = grab_blob(parent, &sz);
215215
parent_file.size = sz;
216+
memset(&xpp, 0, sizeof(xpp));
216217
xpp.flags = XDF_NEED_MINIMAL;
217218
memset(&xecfg, 0, sizeof(xecfg));
218219
memset(&state, 0, sizeof(state));

diff.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
470470
mmfile_t minus, plus;
471471
int i;
472472

473+
memset(&xpp, 0, sizeof(xpp));
473474
memset(&xecfg, 0, sizeof(xecfg));
474475
minus.size = diff_words->minus.text.size;
475476
minus.ptr = xmalloc(minus.size);
@@ -1585,6 +1586,7 @@ static void builtin_diff(const char *name_a,
15851586
if (!pe)
15861587
pe = diff_funcname_pattern(two);
15871588

1589+
memset(&xpp, 0, sizeof(xpp));
15881590
memset(&xecfg, 0, sizeof(xecfg));
15891591
memset(&ecbdata, 0, sizeof(ecbdata));
15901592
ecbdata.label_path = lbl;
@@ -1658,6 +1660,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
16581660
xdemitconf_t xecfg;
16591661
xdemitcb_t ecb;
16601662

1663+
memset(&xpp, 0, sizeof(xpp));
16611664
memset(&xecfg, 0, sizeof(xecfg));
16621665
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
16631666
xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
@@ -1704,6 +1707,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
17041707
xdemitconf_t xecfg;
17051708
xdemitcb_t ecb;
17061709

1710+
memset(&xpp, 0, sizeof(xpp));
17071711
memset(&xecfg, 0, sizeof(xecfg));
17081712
xecfg.ctxlen = 1; /* at least one context line */
17091713
xpp.flags = XDF_NEED_MINIMAL;
@@ -3149,6 +3153,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
31493153
struct diff_filepair *p = q->queue[i];
31503154
int len1, len2;
31513155

3156+
memset(&xpp, 0, sizeof(xpp));
31523157
memset(&xecfg, 0, sizeof(xecfg));
31533158
if (p->status == 0)
31543159
return error("internal diff status error");

merge-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
6161
xdemitconf_t xecfg;
6262
xdemitcb_t ecb;
6363

64+
memset(&xpp, 0, sizeof(xpp));
6465
xpp.flags = XDF_NEED_MINIMAL;
6566
memset(&xecfg, 0, sizeof(xecfg));
6667
xecfg.ctxlen = 3;

0 commit comments

Comments
 (0)