Index: matcher/multiandpostlist.cc
===================================================================
--- matcher/multiandpostlist.cc	(revision 12831)
+++ matcher/multiandpostlist.cc	(working copy)
@@ -194,7 +194,12 @@
 	return NULL;
     }
     did = plist[0]->get_docid();
+    Xapian::weight max_remaining = max_total - (max_wt[0] - plist[0]->get_weight());
     for (size_t i = 1; i < n_kids; ++i) {
+	if (max_remaining < w_min) {
+	    next_helper(0, w_min);
+	    goto advanced_plist0;
+	}
 	bool valid;
 	check_helper(i, did, w_min, valid);
 	if (!valid) {
@@ -210,6 +215,7 @@
 	    skip_to_helper(0, new_did, w_min);
 	    goto advanced_plist0;
 	}
+	max_remaining -= max_wt[i] - plist[i]->get_weight();
     }
     return NULL;
 }
