[Pkg-gnupg-commit] [gnupg2] 12/132: gpgscm: Initialize unused slots in vectors.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed May 17 03:07:35 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gnupg2.
commit b83903f59ec5d49ac579f263da70ebc8dc3645b5
Author: Justus Winter <justus at g10code.com>
Date: Thu Apr 6 16:21:48 2017 +0200
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 at g10code.com>
---
tests/gpgscm/scheme.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c
index 51fdef0..3719e53 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;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list