This project is archived and is in readonly mode.

#81 ✓ resolved
Trevor McKay

_mogrify leaks reference when same dict value referenced multiple times with $()

Reported by Trevor McKay | December 5th, 2011 @ 03:49 PM

Discovered in 2.0.13, verified against 2.4.3 from git.

Note, title is wrong, I typed $() instead of %() but I can't find a way to fix it....

If _mogrify is called with an operation string and a dictionary and the operation string references a value from the dict using the %() syntax more than once, a reference to that dict value will be leaked for each reference after the first.

I attached a (very simple) patch for this wich fixes the problem, however being unfamiliar with the code it may not be correct from a wholistic perspective :) Please advise.

We at Red Hat are carrying psycopg2 2.0.13 and 2.0.14 in RHEL 5 and RHEL 6, and it is being packaged at Fedora as well (2.4.2 in F15, in F15+ also I believe). If someone can verify that the patch is legit and approve it, that would be great -- we can carry our own patch until it's available upstream.

I can also attach a simple test program which demonstrates the problem (I assume the bug system will let me submit an additional attachment after creation).

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

WARNING: the informations in this tracker are archived. Please submit new tickets or comments to the new tracker.

Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.

Shared Ticket Bins