[PATCH 3/4] uiemis-downloader.c: fix preceding limit check

Lubomir I. Ivanov neolit123 at gmail.com
Wed Dec 11 05:26:49 UTC 2013


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

next_segment():
The iterator limit check (i < size - 1) should precede
the indexing (buf[i]).

Reported by the program cppcheck.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 uemis-downloader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/uemis-downloader.c b/uemis-downloader.c
index b1d977d..2eaa18c 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -266,7 +266,7 @@ static char *next_segment(char *buf, int *offset, int size)
 
 	while (!done) {
 		if (i < size) {
-			if (buf[i] == '\\' && i < size - 1 &&
+			if (i < size - 1 && buf[i] == '\\' &&
 				(buf[i+1] == '\\' || buf[i+1] == '{'))
 				memcpy(buf + i, buf + i + 1, size - i - 1);
 			else if (buf[i] == '{')
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list