Browse Source

Handle empty lines in server history

tags/v1.12.90
Pierre Ossman 2 years ago
parent
commit
1f56a8b0db
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      vncviewer/ServerDialog.cxx

+ 8
- 4
vncviewer/ServerDialog.cxx View File

lineNr, filepath, strerror(errno)); lineNr, filepath, strerror(errno));
} }


if (strlen(line) == (sizeof(line) - 1)) {
int len = strlen(line);

if (len == (sizeof(line) - 1)) {
fclose(f); fclose(f);
throw Exception(_("Failed to read line %d in file %s: %s"), throw Exception(_("Failed to read line %d in file %s: %s"),
lineNr, filepath, _("Line too long")); 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'; line[len-1] = '\0';
len--; len--;
} }
if (line[len-1] == '\r') {
if ((len > 0) && (line[len-1] == '\r')) {
line[len-1] = '\0'; line[len-1] = '\0';
len--; len--;
} }


if (len == 0)
continue;

serverHistory.push_back(line); serverHistory.push_back(line);
} }



Loading…
Cancel
Save