Commit ef715580e9762ea2c96890bbfc8eda58f04181cd

Stefan Sperling 2018-01-26T15:01:44

ensure we don't call closedir(NULL) in search_packidx()

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/lib/pack.c b/lib/pack.c
index edc9583..f5d5be0 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -356,7 +356,7 @@ search_packidx(struct got_packidx_v2_hdr **packidx, int *idx,
 	err = got_error(GOT_ERR_NO_OBJ);
 done:
 	free(path_packdir);
-	if (closedir(packdir) != 0 && err == 0)
+	if (packdir && closedir(packdir) != 0 && err == 0)
 		err = got_error_from_errno();
 	return err;
 }