Fixed access to freed memory in conn_get_isolation_level().

Bug reported by Anton Kovalev.
This commit is contained in:
Daniele Varrazzo 2010-10-08 12:02:53 +01:00
parent 850cd97ab3
commit baf65a0dda
2 changed files with 13 additions and 4 deletions

View File

@ -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.

View File

@ -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