summaryrefslogtreecommitdiff
path: root/src/version.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-01-03 19:15:35 +0200
committerTimo Teräs <timo.teras@iki.fi>2011-01-03 19:15:35 +0200
commit1f42cc1aed32ebf160db5e812d2f57e654042522 (patch)
tree69eb7f56dae5303178567b27234cdbfd3537c6bb /src/version.c
parent1c7e8d2617d93daac1fe0c38c0279435331bb152 (diff)
downloadapk-tools-1f42cc1aed32ebf160db5e812d2f57e654042522.tar.gz
apk-tools-1f42cc1aed32ebf160db5e812d2f57e654042522.tar.bz2
apk-tools-1f42cc1aed32ebf160db5e812d2f57e654042522.tar.xz
apk-tools-1f42cc1aed32ebf160db5e812d2f57e654042522.zip
version: fix evaluation order to make valgrind happy
otherwise we get reads from uninitialized/unallocated memory.
Diffstat (limited to 'src/version.c')
-rw-r--r--src/version.c4
1 files changed, 2 insertions, 2 deletions
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';
}