Skip to content

Commit 60df0da

Browse files
committed
[fix] Variable initialization fixes for libxdiff
Signed-off-by: David Cantrell <[email protected]>
1 parent 240846d commit 60df0da

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

libxdiff/xdiffi.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,12 @@ static void xdl_mark_ignorable(xdchange_t *xscr, xdfenv_t *xe, long flags)
578578

579579
int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
580580
xdemitconf_t const *xecfg, xdemitcb_t *ecb) {
581-
xdchange_t *xscr;
581+
xdchange_t *xscr = NULL;
582582
xdfenv_t xe;
583583
emit_func_t ef = xecfg->hunk_func ? xdl_call_hunk_func : xdl_emit_diff;
584584

585+
memset(&xe, 0, sizeof(xe));
586+
585587
if (xdl_do_diff(mf1, mf2, xpp, &xe) < 0) {
586588

587589
return -1;

libxdiff/xemit.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ static long get_func_line(xdfenv_t *xe, xdemitconf_t const *xecfg,
165165

166166
int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg)
167167
{
168-
unsigned long s1, s2, e1, e2, lctx;
169-
xdchange_t *xch, *xche;
168+
unsigned long s1 = 0, s2 = 0, e1 = 0, e2 = 0, lctx = 0;
169+
xdchange_t *xch = NULL, *xche = NULL;
170170
unsigned long funclineprev = -1;
171171
struct func_line func_line = { 0 };
172172

libxdiff/xutils.c

+3
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ int xdl_emit_hunk_hdr(long unsigned s1, long unsigned c1, long unsigned s2, long
420420
mmbuffer_t mb;
421421
char buf[128];
422422

423+
memset(&mb, 0, sizeof(mb));
424+
423425
memcpy(buf, "@@ -", 4);
424426
nb += 4;
425427

@@ -457,6 +459,7 @@ int xdl_emit_hunk_hdr(long unsigned s1, long unsigned c1, long unsigned s2, long
457459

458460
mb.ptr = buf;
459461
mb.size = nb;
462+
460463
if (ecb->outf(ecb->priv, &mb, 1) < 0)
461464
return -1;
462465

0 commit comments

Comments
 (0)