From 1f42cc1aed32ebf160db5e812d2f57e654042522 Mon Sep 17 00:00:00 2001
From: Timo Teräs <timo.teras@iki.fi>
Date: Mon, 3 Jan 2011 19:15:35 +0200
Subject: version: fix evaluation order to make valgrind happy

otherwise we get reads from uninitialized/unallocated memory.
---
 src/version.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'src')

diff --git a/src/version.c b/src/version.c
index 2de886a..15757bc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -85,7 +85,7 @@ static int get_token(int *type, apk_blob_t *blob)
 	case TOKEN_DIGIT_OR_ZERO:
 		/* Leading zero digits get a special treatment */
 		if (blob->ptr[i] == '0') {
-			while (blob->ptr[i] == '0' && i < blob->len)
+			while (i < blob->len && blob->ptr[i] == '0')
 				i++;
 			nt = TOKEN_DIGIT;
 			v = -i;
@@ -94,7 +94,7 @@ static int get_token(int *type, apk_blob_t *blob)
 	case TOKEN_DIGIT:
 	case TOKEN_SUFFIX_NO:
 	case TOKEN_REVISION_NO:
-		while (isdigit(blob->ptr[i]) && i < blob->len) {
+		while (i < blob->len && isdigit(blob->ptr[i])) {
 			v *= 10;
 			v += blob->ptr[i++] - '0';
 		}
-- 
cgit v1.2.3-70-g09d2