[bug fix] ECPG: freeing memory for pgtypes crashes on Windows

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "Michael Meskes (meskes(at)postgresql(dot)org)" <meskes(at)postgresql(dot)org>
Subject: [bug fix] ECPG: freeing memory for pgtypes crashes on Windows
Date: 2018-02-02 02:47:27
Message-ID: 0A3221C70F24FB45833433255569204D1F8AD5D6@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

Some user hit a problem with ECPG on Windows. The attached patch is a fix for it. I'd appreciate it if you could backport this in all supported versions.

The problem is simple. free() in the following example crashes:

char *out;

out = PGTYPESnumeric_to_asc(...);
free(out);

The cause is the mismatch of the version of C runtime library. The version of Visual Studio used to build the application was different from that for building PostgreSQL (libpgtypes.dll).

The fix is to add PGTYPES_free() in libpgtypes.dll, just like libpq has PQfreemem() described here:

https://www.postgresql.org/docs/devel/static/libpq-misc.html

Regards
Takayuki Tsunakawa

Attachment Content-Type Size
pgtypes_freemem.patch application/octet-stream 39.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2018-02-02 02:48:14 Re: Wait for parallel workers to attach
Previous Message Amit Kapila 2018-02-02 02:46:52 Re: Re: BUG #15039: some question about hash index code