Re: Patch for PGunescapeBytea - Mailing list pgsql-patches

From Magnus Naeslund(f)
Subject Re: Patch for PGunescapeBytea
Date
Msg-id 00e001c31325$cf4b92a0$f80c0a0a@mnd
Whole thread Raw
In response to Patch for PGunescapeBytea  (Ben Lamb <pgsql-patches@zurgy.org>)
Responses Re: Patch for PGunescapeBytea  (Ben Lamb <pgsql-patches@zurgy.org>)
Re: Patch for PGunescapeBytea  (Ben Lamb <pgsql-patches@zurgy.org>)
List pgsql-patches
Ben Lamb <pgsql-patches@zurgy.org> wrote:
>> Hi,
>>
>> I found the libpq function PGunescapeBytea a little slow. It was
>> taking a minute and a half to decode a 500Kb on a fairly fast
>> machine. I think the culprit is sscanf.
[snip]

I think these lines:

buffer = realloc(buffer, buflen);
---
if (buffer == NULL)
    return NULL;
---

are wrong. Shouldn't one do:
---
tmpbuf=realloc(buf,...);
if (!tmpbuf)
    free(buf), return 0;
---

to avoid a memory leak?

... just checking ;)

Magnus


pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Disable alternate locations on Win32
Next
From: Ben Lamb
Date:
Subject: Re: Patch for PGunescapeBytea