Commit 7b366981c181847ca7ddee5d703737ad12ee7184

Stefan Sperling 2018-04-02T19:24:14

always free ds->J in got_diffreg()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/lib/diffreg.c b/lib/diffreg.c
index f6a314e..e46456d 100644
--- a/lib/diffreg.c
+++ b/lib/diffreg.c
@@ -396,8 +396,6 @@ got_diffreg(int *rval, FILE *f1, FILE *f2, int flags,
 	p = reallocarray(ds->J, ds->len[0] + 2, sizeof(*ds->J));
 	if (p == NULL) {
 		err = got_error_from_errno();
-		free(ds->J);
-		ds->J = NULL;
 		goto closem;
 	}
 	ds->J = p;
@@ -428,6 +426,7 @@ got_diffreg(int *rval, FILE *f1, FILE *f2, int flags,
 	    flags))
 		err = got_error_from_errno();
 closem:
+	free(ds->J);
 	free(ds->member);
 	free(ds->class);
 	if (ds->anychange) {