Ver Fonte

fixes coverity issue 141838

Sebastian Stenzel há 8 anos atrás
pai
commit
3b3ebd2196

+ 6 - 1
main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/CommandRunner.java

@@ -61,13 +61,18 @@ final class CommandRunner {
 	static CommandResult execute(Script script, long timeout, TimeUnit unit) throws CommandFailedException {
 		try {
 			final List<String> env = script.environment().entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.toList());
+			final String[] lines = script.getLines();
+			if (lines.length == 0) {
+				throw new IllegalArgumentException("Invalid script");
+			}
 			CommandResult result = null;
-			for (final String line : script.getLines()) {
+			for (final String line : lines) {
 				final String[] cmds = ArrayUtils.add(determineCli(), line);
 				final Process proc = Runtime.getRuntime().exec(cmds, env.toArray(new String[0]));
 				result = run(proc, timeout, unit);
 				result.assertOk();
 			}
+			assert result != null;
 			return result;
 		} catch (IOException e) {
 			throw new CommandFailedException(e);