Commit 718ef3e9e896770be288214c9e03de887cb683cd

Stefan Sperling 2019-08-11T20:15:17

simplify cleanup code paths in got_path_find_prog()

diff --git a/lib/path.c b/lib/path.c
index 8ae1c96..be17963 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -438,14 +438,11 @@ got_path_find_prog(char **filename, const char *prog)
 
 		if (asprintf(filename, "%s/%s", p, prog) == -1) {
 			err = got_error_from_errno("asprintf");
-			free(path);
-			return err;
+			break;
 		}
 		if ((stat(*filename, &sbuf) == 0) && S_ISREG(sbuf.st_mode) &&
-		    access(*filename, X_OK) == 0) {
-			free(path);
-			return NULL;
-		}
+		    access(*filename, X_OK) == 0)
+			break;
 		free(*filename);
 		*filename = NULL;
 		continue;