diff options
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | psycopg/connection_int.c | 12 |
2 files changed, 13 insertions, 4 deletions
@@ -1,3 +1,8 @@ +2010-10-08 Daniele Varrazzo <daniele.varrazzo@gmail.com> + + * psycopg/connection_int.c: Fixed access to freed memory in + conn_get_isolation_level(). Bug reported by Anton Kovalev. + 2010-10-05 Daniele Varrazzo <daniele.varrazzo@gmail.com> * psycopg/cursor_type.c: Common code in execute() and mogrify() merged. 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 |
