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]>
Tue, 18 Oct 2016 10:07:44 +0000 (15:37 +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 b092f8c2e438aa309afaffaa578a7c59f6f325f1..510105a975df5f809afad4ae31ea7fe9544afecd 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);
                        }
                }
        }