diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-10-08 12:02:53 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-10-08 12:02:53 +0100 |
| commit | baf65a0ddae18fc89af36bc1bdf44c41686dee1b (patch) | |
| tree | a9fd9dd6a7c52687672cd0008950372b1718a220 /psycopg/connection_int.c | |
| parent | 850cd97ab3df995260b15bdd8df2bf0794b64b1c (diff) | |
| download | psycopg2-baf65a0ddae18fc89af36bc1bdf44c41686dee1b.tar.gz | |
Fixed access to freed memory in conn_get_isolation_level().
Bug reported by Anton Kovalev.
Diffstat (limited to 'psycopg/connection_int.c')
| -rw-r--r-- | psycopg/connection_int.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 574b651..85d47d5 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -217,15 +217,19 @@ conn_get_isolation_level(PGresult *pgres) { static const char lvl1a[] = "read uncommitted"; static const char lvl1b[] = "read committed"; - char *isolation_level = PQgetvalue(pgres, 0, 0); + int rv; - CLEARPGRES(pgres); + char *isolation_level = PQgetvalue(pgres, 0, 0); if ((strncmp(lvl1a, isolation_level, strlen(isolation_level)) == 0) || (strncmp(lvl1b, isolation_level, strlen(isolation_level)) == 0)) - return 1; + rv = 1; else /* if it's not one of the lower ones, it's SERIALIZABLE */ - return 2; + rv = 2; + + CLEARPGRES(pgres); + + return rv; } int |
