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:
parent
23f00f109d
commit
b83903f59e
@ -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)
|
static pointer get_vector_object(scheme *sc, int len, pointer init)
|
||||||
{
|
{
|
||||||
pointer cells = get_consecutive_cells(sc, vector_size(len));
|
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; }
|
if(sc->no_memory) { return sc->sink; }
|
||||||
/* Record it as a vector so that gc understands it. */
|
/* Record it as a vector so that gc understands it. */
|
||||||
typeflag(cells) = (T_VECTOR | T_ATOM | T_FINALIZE);
|
typeflag(cells) = (T_VECTOR | T_ATOM | T_FINALIZE);
|
||||||
vector_length(cells) = len;
|
vector_length(cells) = len;
|
||||||
fill_vector(cells,init);
|
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))
|
if (gc_enabled (sc))
|
||||||
push_recent_alloc(sc, cells, sc->NIL);
|
push_recent_alloc(sc, cells, sc->NIL);
|
||||||
return cells;
|
return cells;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user