From 8b6abc0e35be8177901f7972e7eb6fecffcad366 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Sun, 25 Mar 2018 17:07:38 +0200 Subject: [PATCH] Correctly pre-increment the loopCounter. In case of infinit redirection, if we post-increment the loop counter, we will exit the loop when loopCounter will be 42 and increment it. So loop counter will be 43. Let's pre-increment the counter to still compare with 42 (more consistancy) Fix #168 --- src/server/kiwix-serve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 29862ee..eeb56dd 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -626,7 +626,7 @@ static struct MHD_Response* handle_content(RequestContext* request) if (found) { /* If redirect */ unsigned int loopCounter = 0; - while (article.isRedirect() && loopCounter++ < 42) { + while (article.isRedirect() && ++loopCounter < 42) { article = article.getRedirectArticle(); }