Mercurial > ~mikael > mcabber > hg
diff mcabber/mcabber/compl.c @ 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 | c1f9a4d47e05 |
children | 0cb8ea02e472 |
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;