Bläddra i källkod

Handle empty lines in server history

tags/v1.12.90
Pierre Ossman 2 år sedan
förälder
incheckning
1f56a8b0db
1 ändrade filer med 8 tillägg och 4 borttagningar
  1. 8
    4
      vncviewer/ServerDialog.cxx

+ 8
- 4
vncviewer/ServerDialog.cxx Visa fil

@@ -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);
}


Laddar…
Avbryt
Spara