Skip to content

Commit

Permalink
Display & Candidate: added null checks to robust code, fixes #490
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Dec 18, 2019
1 parent dfc070d commit 0e537cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions reader/src/main/java/org/jline/reader/Candidate.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2018, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -46,9 +46,8 @@ public Candidate(String value) {
* @param complete the complete flag
*/
public Candidate(String value, String displ, String group, String descr, String suffix, String key, boolean complete) {
Objects.requireNonNull(value);
this.value = value;
this.displ = displ;
this.value = Objects.requireNonNull(value);
this.displ = Objects.requireNonNull(displ);
this.group = group;
this.descr = descr;
this.suffix = suffix;
Expand Down
4 changes: 2 additions & 2 deletions terminal/src/main/java/org/jline/utils/Display.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2018, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -488,7 +488,7 @@ void rawPrint(AttributedString str) {
}

public int wcwidth(String str) {
return AttributedString.fromAnsi(str).columnLength();
return str != null ? AttributedString.fromAnsi(str).columnLength() : 0;
}

}

0 comments on commit 0e537cb

Please sign in to comment.