]> granicus.if.org Git - postgresql/commitdiff
Initialize new jsonb iterator to zero
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 29 May 2018 03:53:43 +0000 (23:53 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Tue, 29 May 2018 03:53:43 +0000 (23:53 -0400)
Use palloc0() instead of palloc() to create a new JsonbIterator.
Otherwise, the isScalar field is sometimes not initialized.  There is
probably no impact in practice, but it's cleaner this way and it avoids
future problems.

src/backend/utils/adt/jsonb_util.c

index 2524584d957f140f5f05e60a3b0470fabfb4b17b..3be900f8ee07e7ea2cb5d2600a14330ad91db33a 100644 (file)
@@ -901,7 +901,7 @@ iteratorFromContainer(JsonbContainer *container, JsonbIterator *parent)
 {
        JsonbIterator *it;
 
-       it = palloc(sizeof(JsonbIterator));
+       it = palloc0(sizeof(JsonbIterator));
        it->container = container;
        it->parent = parent;
        it->nElems = JsonContainerSize(container);