Skip to content

Commit

Permalink
Fix StackOverflowError in detached Docker container (fixes jline#941)
Browse files Browse the repository at this point in the history
When running inside a detached Docker container, calling LineReaderImpl.redisplay
resulted in a StackOverflowError. The reason for this is that redisplay eventually
calls doList, which again calls redisplay because the size.getRows() is 0.
  • Loading branch information
Kay Werndli committed Mar 1, 2024
1 parent 19c031c commit 00c9be5
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5006,10 +5006,13 @@ protected boolean doList(
PostResult postResult = computePost(possible, null, null, completed);
int lines = postResult.lines;
int listMax = getInt(LIST_MAX, DEFAULT_LIST_MAX);
if (listMax > 0 && possible.size() >= listMax || lines >= size.getRows() - promptLines) {
int rows = size.getRows();
int possibleSize = possible.size();
if (possibleSize == 0 || rows == 0) return false;
if (listMax > 0 && possibleSize >= listMax || lines >= rows - promptLines) {
if (!forSuggestion) {
// prompt
post = () -> new AttributedString(getAppName() + ": do you wish to see all " + possible.size()
post = () -> new AttributedString(getAppName() + ": do you wish to see all " + possibleSize
+ " possibilities (" + lines + " lines)?");
redisplay(true);
int c = readCharacter();
Expand Down

0 comments on commit 00c9be5

Please sign in to comment.