The new order of test avoid ready invalid memory address in ca.buf
// 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++;
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--;
// Compute output size
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
sz++;
if (*in == '\r') {
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';