]> git.eshelyaron.com Git - emacs.git/commit
Avoid accessing uninitialized bool_vector words
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 20 Jul 2024 07:17:14 +0000 (00:17 -0700)
committerEshel Yaron <me@eshelyaron.com>
Mon, 22 Jul 2024 10:35:27 +0000 (12:35 +0200)
commit63d4de4d8452ac6642e8d29ed2d12ca0ecd866f8
treed3157432fd13144d22fd998d2b13f6550eeb5dec
parent689688270c3ecfba47473878dfc347a77e0b6557
Avoid accessing uninitialized bool_vector words

Although loading uninitialized works from memory and then ignoring
the result works fine on conventional architectures, it
technically has undefined behavior in C, so redo bool_vector
allocation so that the code never does that.  This can improve
performance when allocating large vectors of nil, since calloc can
clear the memory lazily.
* src/alloc.c (make_clear_bool_vector): New function,
a generalization of make_uninit_bool_vector.
(make_uninit_bool_vector): Use it.
(Fmake_bool_vector): If !INIT, rely on make_clear_bool_vector.
* src/alloc.c (Fbool_vector):
* src/fns.c (Freverse): Don’t access uninitialized bool_vector words.

(cherry picked from commit 79b9f05d3a44b25db9fd3eff9cc002324cfa790c)
src/alloc.c
src/fns.c
src/lisp.h