Subject: bug#36596: 27.0.50; `hash-table-count' can return a negative value

From: Pip Cet <[email-masked]>
Date: Thu, 11 Jul 2019 13:17:10 +0000

The attached obvious patch fixes a "trivial oversight" in fns.c, where
we forgot to rehash a dumped table before accessing its ->count.
From ab70a0da6c2a3ac87d69f02c74cb3e35f0997e28 Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Date: Thu, 11 Jul 2019 13:14:06 +0000
Subject: [PATCH] Avoid returning negative numbers from `hash-table-count'

* src/fns.c (Fhash_table_count): Rehash argument if necessary.
---
 src/fns.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/fns.c b/src/fns.c
index 7343556ac2..9c6057b360 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4863,7 +4863,9 @@ DEFUN ("hash-table-count", Fhash_table_count, Shash_table_count, 1, 1, 0,
        doc: /* Return the number of elements in TABLE.  */)
   (Lisp_Object table)
 {
-  return make_fixnum (check_hash_table (table)->count);
+  struct Lisp_Hash_Table *h = check_hash_table (table);
+  hash_rehash_if_needed (h);
+  return make_fixnum (h->count);
 }

-- 
2.20.1