Making totalResult incrementor long to prevent overflow

Change-Id: I400e7355de9e08195effbe8ed2e956ea9c8e250b
diff --git a/Changes b/Changes
index 2bc4b7e..8a924fa 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,8 @@
-0.64.5 2025-11-14
+0.64.5 2025-11-21
     - [maintenance] Update to Java 21 (diewald)
     - [enhancement] Alter vcNamePattern to allow system VC names with less 
       than 3 characters (margaretha)
+    - [bugfix] Making totalResult counter long to prevent overflows (diewald)
 
 0.64.4 2025-09-17
     - [feature] Added --progress option to Krill-Indexer (kupietz)
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index 28b3e0b..431ce7d 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -1423,8 +1423,8 @@
         };
         
         // Some initializations ...
-        int i = 0; // matchcount
-        int j = 0; // matchdoccount
+        long i = 0; // matchcount
+        long j = 0; // matchdoccount
         int startIndex = kr.getStartIndex();
         int count = kr.getItemsPerPage();
         int hits = kr.getItemsPerPage() + startIndex;
@@ -1686,8 +1686,8 @@
             if (itemsPerResource > 0)
                 kr.setItemsPerResource(itemsPerResource);
 
-            kr.setTotalResults(cutoff ? (long) -1 : (long) i);
-            kr.setTotalResources(cutoff ? (long) -1 : (long) j);
+            kr.setTotalResults(cutoff ? (long) -1 : i);
+            kr.setTotalResources(cutoff ? (long) -1 : j);
         }
 
         catch (IOException e) {