Skip to content

Commit

Permalink
Fix potential NULL dereference in Java example code
Browse files Browse the repository at this point in the history
Coverity tells us that getline() can return null. Don't blindly reference
it.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
dwmw2 committed Apr 28, 2021
1 parent 786b420 commit 8ca5868
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion java/src/com/example/LibTest.java
Expand Up @@ -55,7 +55,7 @@ public int onValidatePeerCert(String msg) {

System.out.print("\nAccept this certificate? [n] ");
String s = getline();
if (s.startsWith("y") || s.startsWith("Y")) {
if (s != null && (s.startsWith("y") || s.startsWith("Y"))) {
return 0;
} else {
return -1;
Expand Down

0 comments on commit 8ca5868

Please sign in to comment.