fix type mismatch in slot_deform_datarow (void* vs. Datum)
authorTomas Vondra <[email protected]>
Tue, 23 Aug 2016 08:39:02 +0000 (10:39 +0200)
committerPavan Deolasee <[email protected]>
Thu, 25 Aug 2016 04:44:39 +0000 (10:14 +0530)
The pfree() expects void*, but was getting pointer packed as a Datum.
So instead use 'val' with the Datum converted as a pointer, and also
ditch the pointless null check (we're doing memcpy from the pointer
so we'd get segfault anyway).

src/backend/access/common/heaptuple.c

index ff3b25e32fe5ed89d3bb443b5a5875b03c5f6f9f..ffc48bd8b129f26ac934f8d15b4d6fd432b1f20a 100644 (file)
@@ -1326,10 +1326,9 @@ slot_deform_datarow(TupleTableSlot *slot)
                                data = MemoryContextAlloc(slot->tts_drowcxt, data_length);
                                memcpy(data, val, data_length);
 
-                               if (slot->tts_values[i])
-                                       pfree(slot->tts_values[i]);
+                               pfree(val);
 
-                               slot->tts_values[i] = (Datum) data;
+                               slot->tts_values[i] = PointerGetDatum(data);
                        }
                }
        }