diff --git a/ChangeLog b/ChangeLog index e5afb85f..5c5ef441 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-10-08 Daniele Varrazzo + + * psycopg/connection_int.c: Fixed access to freed memory in + conn_get_isolation_level(). Bug reported by Anton Kovalev. + 2010-10-05 Daniele Varrazzo * psycopg/cursor_type.c: Common code in execute() and mogrify() merged. diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 574b6510..85d47d50 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