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
This commit is contained in:
Matthieu Gautier 2018-03-25 17:20:42 +02:00
parent e23949a9fa
commit 313f6731b0
1 changed files with 2 additions and 2 deletions

View File

@ -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) {