summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>2021-12-15 13:12:02 +0900
committerYAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>2021-12-15 13:12:02 +0900
commit7078f32b5befd90c1f1956a319f4c847b6961f48 (patch)
treec70cc6e2d0c880bf80050d2f853fa6cefdb10ea3
parenta4fcbf46a7bb71c39b22e4f6a865939ee8721d83 (diff)
downloademacs-7078f32b5befd90c1f1956a319f4c847b6961f48.tar.gz
Fix crash when dumping charset_table with portable dumper (Bug#52461)
* src/charset.h: * src/charset.c (charset_table_used): Now extern. * src/pdumper.c (dump_charset): Don't dump code_space_mask for unused slots of charset_table.
-rw-r--r--src/charset.c2
-rw-r--r--src/charset.h1
-rw-r--r--src/pdumper.c4
3 files changed, 4 insertions, 3 deletions
diff --git a/src/charset.c b/src/charset.c
index 7cd0fa78f04..670fd48a2d9 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -63,7 +63,7 @@ Lisp_Object Vcharset_hash_table;
/* Table of struct charset. */
struct charset *charset_table;
int charset_table_size;
-static int charset_table_used;
+int charset_table_used;
/* Special charsets corresponding to symbols. */
int charset_ascii;
diff --git a/src/charset.h b/src/charset.h
index 97122d82a65..8c538234d8d 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -249,6 +249,7 @@ extern Lisp_Object Vcharset_hash_table;
/* Table of struct charset. */
extern struct charset *charset_table;
extern int charset_table_size;
+extern int charset_table_used;
#define CHARSET_FROM_ID(id) (charset_table + (id))
diff --git a/src/pdumper.c b/src/pdumper.c
index 98c760162e1..2782648e7ab 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -3174,7 +3174,7 @@ dump_charset (struct dump_context *ctx, int cs_i)
DUMP_FIELD_COPY (&out, cs, hash_index);
DUMP_FIELD_COPY (&out, cs, dimension);
memcpy (out.code_space, &cs->code_space, sizeof (cs->code_space));
- if (cs->code_space_mask)
+ if (cs_i < charset_table_used && cs->code_space_mask)
dump_field_fixup_later (ctx, &out, cs, &cs->code_space_mask);
DUMP_FIELD_COPY (&out, cs, code_linear_p);
DUMP_FIELD_COPY (&out, cs, iso_chars_96);
@@ -3195,7 +3195,7 @@ dump_charset (struct dump_context *ctx, int cs_i)
memcpy (out.fast_map, &cs->fast_map, sizeof (cs->fast_map));
DUMP_FIELD_COPY (&out, cs, code_offset);
dump_off offset = dump_object_finish (ctx, &out, sizeof (out));
- if (cs->code_space_mask)
+ if (cs_i < charset_table_used && cs->code_space_mask)
dump_remember_cold_op (ctx, COLD_OP_CHARSET,
Fcons (dump_off_to_lisp (cs_i),
dump_off_to_lisp (offset)));