Permalink
Browse files

Fix CID 1386106 (Explicit null dereferenced)

Handle also the case when the user closes the dialog
without selecting an answer.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information...
stweil committed Jun 30, 2018
1 parent b24b2c2 commit 368fa189d1b930ba2c09abae3201a3bf9163f2a8
Showing with 4 additions and 6 deletions.
  1. +4 −6 java/com/google/scrollview/ui/SVWindow.java
@@ -606,20 +606,18 @@ public void showInputDialog(String msg) {
* Shows a dialog presenting "Yes" and "No" as answers and returns either a
* "y" or "n" to the client.
*
* Closing the dialog without answering is handled like "No".
*
* @param msg The text that is displayed in the dialog.
*/
public void showYesNoDialog(String msg) {
// res returns 0 on yes, 1 on no. Seems to be a bit counterintuitive
int res =
JOptionPane.showOptionDialog(this, msg, "", JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE, null, null, null);
SVEvent e = null;
if (res == 0) {
e = new SVEvent(SVEventType.SVET_INPUT, this, 0, 0, 0, 0, "y");
} else if (res == 1) {
e = new SVEvent(SVEventType.SVET_INPUT, this, 0, 0, 0, 0, "n");
}
SVEvent e = new SVEvent(SVEventType.SVET_INPUT, this, 0, 0, 0, 0,
res == 0 ? "y" : "n");
ScrollView.addMessage(e);
}

0 comments on commit 368fa18

Please sign in to comment.