Fix NPE when deleting invalid replies
[Sone.git] / src / main / java / net / pterodactylus / sone / web / DeleteReplyPage.java
index f7ca132..0cd6b4f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - DeleteReplyPage.java - Copyright © 2010–2013 David Roden
+ * Sone - DeleteReplyPage.java - Copyright © 2010–2016 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -58,7 +58,7 @@ public class DeleteReplyPage extends SoneTemplatePage {
                Optional<PostReply> reply = webInterface.getCore().getPostReply(replyId);
                String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                if (request.getMethod() == Method.POST) {
-                       if (!reply.get().getSone().isLocal()) {
+                       if (!reply.isPresent() || !reply.get().getSone().isLocal()) {
                                throw new RedirectException("noPermission.html");
                        }
                        if (request.getHttpRequest().isPartSet("confirmDelete")) {