From: Roland Schulz Date: Tue, 22 Apr 2014 19:51:29 +0000 (-0400) Subject: Fix memory error in asc format IO X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=2d79ca12f227ce79bba2c63d43ac8b4e2960fd65;p=alexxy%2Fgromacs.git Fix memory error in asc format IO Found with cppcheck 1.64 Change-Id: I72e80cd2b11559be47d449d0a8d444857843979b --- diff --git a/src/gmxlib/gmxfio_asc.c b/src/gmxlib/gmxfio_asc.c index ef9870dd6c..0e38211c45 100644 --- a/src/gmxlib/gmxfio_asc.c +++ b/src/gmxlib/gmxfio_asc.c @@ -108,7 +108,7 @@ static void encode_string(int maxlen, char dst[], const char src[]) { int i; - for (i = 0; (src[i] != '\0') && (i < maxlen - 1); i++) + for (i = 0; (i < maxlen - 1) && (src[i] != '\0'); i++) { if ((src[i] == ' ') || (src[i] == '\t')) { @@ -131,7 +131,7 @@ static void decode_string(int maxlen, char dst[], const char src[]) { int i; - for (i = 0; (src[i] != '\0') && (i < maxlen - 1); i++) + for (i = 0; (i < maxlen - 1) && (src[i] != '\0'); i++) { if (src[i] == '_') {