aboutsummaryrefslogtreecommitdiffstats
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-25 13:25:43 +0200
commit772f417cd78ffdac6a5c0adef6d29002b1211597 (patch)
tree7cf909319d887e27e33ae30df70fdb352bab81dc
parent974a73163419fb2d84311d94914a9f93c597053b (diff)
downloadapk-tools-772f417cd78ffdac6a5c0adef6d29002b1211597.tar.gz
apk-tools-772f417cd78ffdac6a5c0adef6d29002b1211597.tar.bz2
apk-tools-772f417cd78ffdac6a5c0adef6d29002b1211597.tar.xz
version: fix evaluation order to make valgrind happy
otherwise we get reads from uninitialized/unallocated memory. (cherry picked from commit 1f42cc1aed32ebf160db5e812d2f57e654042522)
-rw-r--r--src/version.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/version.c b/src/version.c
index 34c5f1a..3c9e139 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';
}