diff options
author | Pierre Ossman <ossman@cendio.se> | 2021-12-23 16:00:20 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2021-12-23 16:00:20 +0100 |
commit | 1f56a8b0db7a316c07af1fb902110207e247da8c (patch) | |
tree | 7a4c665ea827966758b80d464752750fd40a9cec | |
parent | 2daf4126882f82b6e392dfbae87205dbdc559c3d (diff) | |
download | tigervnc-1f56a8b0db7a316c07af1fb902110207e247da8c.tar.gz tigervnc-1f56a8b0db7a316c07af1fb902110207e247da8c.zip |
Handle empty lines in server history
-rw-r--r-- | vncviewer/ServerDialog.cxx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx index 37fffc1c..f2f4113a 100644 --- a/vncviewer/ServerDialog.cxx +++ b/vncviewer/ServerDialog.cxx @@ -349,22 +349,26 @@ void ServerDialog::loadServerHistory() lineNr, filepath, strerror(errno)); } - if (strlen(line) == (sizeof(line) - 1)) { + int len = strlen(line); + + if (len == (sizeof(line) - 1)) { fclose(f); throw Exception(_("Failed to read line %d in file %s: %s"), lineNr, filepath, _("Line too long")); } - int len = strlen(line); - if (line[len-1] == '\n') { + if ((len > 0) && (line[len-1] == '\n')) { line[len-1] = '\0'; len--; } - if (line[len-1] == '\r') { + if ((len > 0) && (line[len-1] == '\r')) { line[len-1] = '\0'; len--; } + if (len == 0) + continue; + serverHistory.push_back(line); } |