From 313f6731b071eedc8df184c37576087b954b2fdc Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Sun, 25 Mar 2018 17:20:42 +0200 Subject: [PATCH] Correctly pre-increment loopCounter. If we check the later the `loopCounter` with 42, we must pre-increment the content. Else, in case of infinite loop, the `loopCounter` will be 43. Related to kiwix/kiwix-tools#168 --- src/android/kiwixreader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/android/kiwixreader.cpp b/src/android/kiwixreader.cpp index e4c6c5d8d..ba3e562f4 100644 --- a/src/android/kiwixreader.cpp +++ b/src/android/kiwixreader.cpp @@ -255,7 +255,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_kiwix_kiwixlib_JNIKiwixReader_getContentPa return data; } int loopCounter = 0; - while (article.isRedirect() && loopCounter++ < 42) { + while (article.isRedirect() && ++loopCounter < 42) { article = article.getRedirectArticle(); } if (loopCounter == 42) { @@ -294,7 +294,7 @@ Java_org_kiwix_kiwixlib_JNIKiwixReader_getDirectAccessInformation( return pair; } int loopCounter = 0; - while (article.isRedirect() && loopCounter++ < 42) { + while (article.isRedirect() && ++loopCounter < 42) { article = article.getRedirectArticle(); } if (loopCounter == 42) {