do not abuse d3s->fp[0] as a local variable in diff3.c's readin()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/lib/diff3.c b/lib/diff3.c
index 8209ffc..5532125 100644
--- a/lib/diff3.c
+++ b/lib/diff3.c
@@ -575,16 +575,17 @@ static const struct got_error *
readin(size_t *n, char *name, struct diff **dd, struct diff3_state *d3s)
{
const struct got_error *err = NULL;
+ FILE *f;
int a, b, c, d;
char kind, *p;
size_t i;
*n = 0;
- d3s->fp[0] = fopen(name, "r");
- if (d3s->fp[0] == NULL)
+ f = fopen(name, "r");
+ if (f == NULL)
return got_error_from_errno2("fopen", name);
- err = getchange(&p, d3s->fp[0], d3s);
+ err = getchange(&p, f, d3s);
if (err)
return err;
for (i = 0; p; i++) {
@@ -615,7 +616,7 @@ readin(size_t *n, char *name, struct diff **dd, struct diff3_state *d3s)
(*dd)[i].new.from = c;
(*dd)[i].new.to = d;
- err = getchange(&p, d3s->fp[0], d3s);
+ err = getchange(&p, f, d3s);
if (err)
return err;
}
@@ -625,7 +626,7 @@ readin(size_t *n, char *name, struct diff **dd, struct diff3_state *d3s)
(*dd)[i].new.from = (*dd)[i - 1].new.to;
}
- if (fclose(d3s->fp[0]) != 0)
+ if (fclose(f) != 0)
err = got_error_from_errno("fclose");
*n = i;