Fix uninitialized memory access.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 21 Jan 2015 17:49:19 +0000 (19:49 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 21 Jan 2015 17:49:19 +0000 (19:49 +0200)
Introduced by the big libpq patch. Before that, the keyset array was
allocated - and zeroed - in another function.

Spotted by Valgrind.

qresult.c

index e87880af238e8e76c344894060b8a75714107dca..045b88cc61791c1d9983993c1229f2d13e258636 100644 (file)
--- a/qresult.c
+++ b/qresult.c
@@ -811,6 +811,9 @@ inolog("QR_get_tupledata %p->num_fields=%d\n", self, self->num_fields);
            else
                tuple_size *= 2;
            QR_REALLOC_return_with_error(self->keyset, KeySet, sizeof(KeySet) * tuple_size, self, "Out of mwmory while allocating keyset", FALSE);
+           memset(self->keyset + self->count_keyset_allocated * sizeof(KeySet),
+                  0,
+                  (tuple_size - self->count_keyset_allocated) * sizeof(KeySet));
            self->count_keyset_allocated = tuple_size;
        }
    }