From 6cea339697bde657e0e733dcb69f7c3d1b079e8e Mon Sep 17 00:00:00 2001 From: Dan Farina Date: Fri, 10 Dec 2010 12:50:52 -0800 Subject: [PATCH] Fix a use-after-free A result is being cleared while there are still pointers that refer to datums in it. Signed-off-by: Dan Farina Signed-off-by: Peter van Hardenberg --- dbutils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dbutils.c b/dbutils.c index 9a771dfd..ebe8373e 100644 --- a/dbutils.c +++ b/dbutils.c @@ -1,6 +1,8 @@ /* * dbutils.c + * * Copyright (c) 2ndQuadrant, 2010 + * Copyright (c) Heroku, 2010 * * Database connection/management functions * @@ -91,7 +93,6 @@ pg_version(PGconn *conn) major_version1 = atoi(PQgetvalue(res, 0, 0)); major_version2 = PQgetvalue(res, 0, 1); - PQclear(res); major_version = malloc(major_version_sz); @@ -104,6 +105,8 @@ pg_version(PGconn *conn) else strcpy(major_version, ""); + PQclear(res); + return major_version; }