unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#36596: 27.0.50; `hash-table-count' can return a negative value
@ 2019-07-11 13:17 Pip Cet
  2019-07-14  4:47 ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Pip Cet @ 2019-07-11 13:17 UTC (permalink / raw)
  To: 36596

[-- Attachment #1: Type: text/plain, Size: 136 bytes --]

The attached obvious patch fixes a "trivial oversight" in fns.c, where
we forgot to rehash a dumped table before accessing its ->count.

[-- Attachment #2: 0001-Avoid-returning-negative-numbers-from-hash-table-cou.patch --]
[-- Type: text/x-patch, Size: 836 bytes --]

From ab70a0da6c2a3ac87d69f02c74cb3e35f0997e28 Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#36596: 27.0.50; `hash-table-count' can return a negative value
  2019-07-11 13:17 bug#36596: 27.0.50; `hash-table-count' can return a negative value Pip Cet
@ 2019-07-14  4:47 ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2019-07-14  4:47 UTC (permalink / raw)
  To: Pip Cet; +Cc: 36596-done

Thanks, I installed that patch.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-14  4:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11 13:17 bug#36596: 27.0.50; `hash-table-count' can return a negative value Pip Cet
2019-07-14  4:47 ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).