1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

gpgscm: Initialize unused slots in vectors.

* tests/gpgscm/scheme.c (get_vector_object): Initialize unused slots
at the end of vectors.
--

They should not be used for anything, but let's just initialize them
to something benign to be sure.

GnuPG-bug-id: 3014
Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2017-04-06 16:21:48 +02:00
parent 23f00f109d
commit b83903f59e
No known key found for this signature in database
GPG Key ID: DD1A52F9DA8C9020

View File

@ -1083,11 +1083,19 @@ static pointer get_cell(scheme *sc, pointer a, pointer b)
static pointer get_vector_object(scheme *sc, int len, pointer init)
{
pointer cells = get_consecutive_cells(sc, vector_size(len));
int i;
int alloc_len = 1 + 3 * (vector_size(len) - 1);
if(sc->no_memory) { return sc->sink; }
/* Record it as a vector so that gc understands it. */
typeflag(cells) = (T_VECTOR | T_ATOM | T_FINALIZE);
vector_length(cells) = len;
fill_vector(cells,init);
/* Initialize the unused slots at the end. */
assert (alloc_len - len < 3);
for (i = len; i < alloc_len; i++)
cells->_object._vector._elements[i] = sc->NIL;
if (gc_enabled (sc))
push_recent_alloc(sc, cells, sc->NIL);
return cells;