too many pfree in large object - Mailing list pgsql-hackers

From t-ishii@sra.co.jp (Tatsuo Ishii)
Subject too many pfree in large object
Date
Msg-id 199810031432.XAA22238@meshsv26.tk.mesh.ad.jp
Whole thread Raw
Responses Re: [HACKERS] too many pfree in large object  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
Hi, there's a small bug in inv_fetchup().
In the following do-while loop, res is freed at the very
end of the loop. However, after getting out of the loop,
it gets freed again. Not good. Possible fix would be
changing the pfree(res) in the loop to:

  if (tuple == (HeapTuple)NULL) pfree(res);

------------------- inv_api.c ----------------------
        do
        {
            res = index_getnext(obj_desc->iscan, ForwardScanDirection);

            if (res == (RetrieveIndexResult) NULL)
            {
                ItemPointerSetInvalid(&(obj_desc->htid));
                return (HeapTuple) NULL;
            }

            /*
             * For time travel, we need to use the actual time qual here,
             * rather that NowTimeQual.  We currently have no way to pass
             * a time qual in.
             *
             * This is now valid for snapshot !!! And should be fixed in some
             * way...    - vadim 07/28/98
             *
             */

            tuple = heap_fetch(obj_desc->heap_r, SnapshotNow,
                               &res->heap_iptr, buffer);
            pfree(res);
        } while (tuple == (HeapTuple) NULL);

        /* remember this tid -- we may need it for later reads/writes */
        ItemPointerCopy(&(res->heap_iptr), &(obj_desc->htid));
        pfree(res);
    }
------------------- inv_api.c -----------------
--
Tatsuo Ishii
t-ishii@sra.co.jp


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Open 6.4 items
Next
From: Bruce Momjian
Date:
Subject: Re: [COMMITTERS] 'pgsql/doc README.ipaddr'