From: Benoit Gschwind Date: Fri, 30 Aug 2019 18:48:16 +0000 (+0200) Subject: fix test order in convertLF and convertCRLF X-Git-Tag: v1.9.90~4^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F866%2Fhead;p=tigervnc.git fix test order in convertLF and convertCRLF The new order of test avoid ready invalid memory address in ca.buf --- diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx index fc4f4ca4..f310263d 100644 --- a/common/rfb/util.cxx +++ b/common/rfb/util.cxx @@ -127,7 +127,7 @@ namespace rfb { // Compute output size in = src; in_len = bytes; - while ((*in != '\0') && (in_len > 0)) { + while ((in_len > 0) && (*in != '\0')) { if (*in != '\r') { sz++; in++; @@ -150,7 +150,7 @@ namespace rfb { out = buffer; in = src; in_len = bytes; - while ((*in != '\0') && (in_len > 0)) { + while ((in_len > 0) && (*in != '\0')) { if (*in != '\r') { *out++ = *in++; in_len--; @@ -182,7 +182,7 @@ namespace rfb { // Compute output size in = src; in_len = bytes; - while ((*in != '\0') && (in_len > 0)) { + while ((in_len > 0) && (*in != '\0')) { sz++; if (*in == '\r') { @@ -205,7 +205,7 @@ namespace rfb { out = buffer; in = src; in_len = bytes; - while ((*in != '\0') && (in_len > 0)) { + while ((in_len > 0) && (*in != '\0')) { if (*in == '\n') { if ((in == src) || (*(in-1) != '\r')) *out++ = '\r';