Re: [HACKERS] Potential for bugs while using COPY_POINTER_FIELD to copy NULL pointer

2012-04-09 Thread Tom Lane
Ashutosh Bapat writes: > After such a copy tests like if (pointer) will start failing. There are few > callers of COPY_POINTER_FIELD which do not call the macro if the size can > be 0. But there are some who do not do so. This looks fishy, in case we > have if (pointer) kinds of cases. I don't th

[HACKERS] Potential for bugs while using COPY_POINTER_FIELD to copy NULL pointer

2012-04-09 Thread Ashutosh Bapat
Hi, COPY_POINTER_FIELD is defined as - 61 #define COPY_POINTER_FIELD(fldname, sz) \ 62 do { \ 63 Size_size = (sz); \ 64 newnode->fldname = palloc(_size); \ 65 memcpy(newnode->fldname, from->fldname, _size); \ 66 } while (0) Since we allocate _size me