Skip to content

Commit

Permalink
Fix CID 1386106 (Explicit null dereferenced)
Browse files Browse the repository at this point in the history
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 368fa18
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions java/com/google/scrollview/ui/SVWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 368fa18

Please sign in to comment.