Skip to content

Commit c06c714

Browse files
committed
fix NullPointerException when no selected ALPN available
1 parent bb97579 commit c06c714

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/java/com/wolfssl/WolfSSLSession.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2840,10 +2840,18 @@ public byte[] getAlpnSelected() throws IllegalStateException {
28402840
*/
28412841
public String getAlpnSelectedString() throws IllegalStateException {
28422842

2843+
byte[] alpnSelectedBytes = null;
2844+
28432845
if (this.active == false)
28442846
throw new IllegalStateException("Object has been freed");
28452847

2846-
return new String(getAlpnSelected(), StandardCharsets.UTF_8);
2848+
alpnSelectedBytes = getAlpnSelected();
2849+
2850+
if (alpnSelectedBytes != null) {
2851+
return new String(alpnSelectedBytes, StandardCharsets.UTF_8);
2852+
} else {
2853+
return null;
2854+
}
28472855
}
28482856

28492857
/**

0 commit comments

Comments
 (0)