Commit e227880da6b6dbda2bf5abdb2156003ec64a733e

Tracey Emery 2020-02-17T17:22:07

improve closedir error handling

diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 16847fa..e0e53c3 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -1629,7 +1629,8 @@ done:
 errored:
 	free(dir_test);
 	if (opened)
-		closedir(dt);
+		if (d && closedir(dt) == -1 && error == NULL)
+			error = got_error_from_errno("closedir");
 	return error;
 }
 
@@ -1687,7 +1688,8 @@ gw_load_got_paths(struct gw_trans *gw_trans)
 		}
 	}
 done:
-	closedir(d);
+	if (d && closedir(d) == -1 && error == NULL)
+		error = got_error_from_errno("closedir");
 	return error;
 }