From b83903f59ec5d49ac579f263da70ebc8dc3645b5 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 6 Apr 2017 16:21:48 +0200 Subject: [PATCH] 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 --- tests/gpgscm/scheme.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c index 51fdef04c..3719e5356 100644 --- a/tests/gpgscm/scheme.c +++ b/tests/gpgscm/scheme.c @@ -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;