changeset 2035:dac609275117

Fix endless loop on exhaustion of completion category pool
author Myhailo Danylenko <isbear@ukrpost.net>
date Sun, 14 Oct 2012 18:06:50 +0200
parents c7d40b9b2bb9
children f8958ab545ac
files mcabber/mcabber/compl.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/compl.c	Sun Oct 14 17:56:34 2012 +0200
+++ b/mcabber/mcabber/compl.c	Sun Oct 14 18:06:50 2012 +0200
@@ -97,10 +97,11 @@
 // as it is likely to change in future.
 guint compl_new_category(void)
 {
+  const guint maxcat = 8 * sizeof (registered_cats);
   guint i = 0;
-  while ((registered_cats >> i) & 1)
+  while ((registered_cats >> i) & 1 && i < maxcat)
     i++;
-  if (i >= 8 * sizeof (registered_cats))
+  if (i >= maxcat)
     return 0;
   else {
     guint64 id = 1 << i;