On Tue, Jul 2, 2019 at 1:27 AM Tom Lane <t...@sss.pgh.pa.us> wrote:

>
> So I think this is a win, and attached is v7.
>

Not related to the diff v6..v7, but shouldn't we throw additionally a
memset() with '\0' before calling pfree():

+        ListCell   *newelements;
+
+        newelements = (ListCell *)
+            MemoryContextAlloc(GetMemoryChunkContext(list),
+                               new_max_len * sizeof(ListCell));
+        memcpy(newelements, list->elements,
+               list->length * sizeof(ListCell));
+        pfree(list->elements);
+        list->elements = newelements;

Or is this somehow ensured by debug pfree() implementation or does it work
differently together with Valgrind?

Otherwise it seems that the calling code can still be hanging onto a list
element from a freed chunk and (rather) happily accessing it, as opposed to
almost ensured crash if that is zeroed before returning from enlarge_list().

Cheers,
--
Alex

Reply via email to