Subject: bug#78943: feature/igc [PATCH] Trace current minor maps exactly

From: Pip Cet <[email-masked]>
Date: Wed, 09 Jul 2025 14:29:29 +0000

"Helmut Eller" <[email-masked]> writes:

> From 3a1a4549a0545afbddc96a87b404b6c7b835d5b7 Mon Sep 17 00:00:00 2001
> From: Helmut Eller <[email-masked]>
> Date: Wed, 2 Jul 2025 14:10:56 +0200
> Subject: [PATCH] Trace current minor maps exactly
>
> * src/keymap.c (current_minor_maps): Use igc_xalloc_lisp_objs_exact
> instead of igc_xzalloc_ambig.

Thanks, LGTM.  Hope that applies to the other accumulated patches, too,
then I'll install them all.

This is a preexisting bug, but I'm suspicious about the code leaking a
pointer to an igc_xzalloc'd area to its caller, which may call Lisp
(when it autoloads a map) in the case of Fminor_mode_key_binding.  If
that Lisp code recursively accesses keymaps and the maps get
reallocated, we end up resurrecting free'd data, and will probably
crash.  (My suspicion is this is the reason for the "don't use realloc"
comment, too).

We should really fix this on master and just use vectors, and it's
probably even less effort for you to do so than it is for me, but I
still don't get how code like this is meant to be fixed.

(I hope the comment about static being defined to the empty string is no
longer accurate :-) ).

Pip