Parcourir la source

Handle empty lines in server history

tags/v1.12.90
Pierre Ossman il y a 2 ans
Parent
révision
1f56a8b0db
1 fichiers modifiés avec 8 ajouts et 4 suppressions
  1. 8
    4
      vncviewer/ServerDialog.cxx

+ 8
- 4
vncviewer/ServerDialog.cxx Voir le fichier

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


Chargement…
Annuler
Enregistrer