From: Andreas Steffen Date: Sun, 6 Apr 2014 15:26:52 +0000 (+0200) Subject: Fixed dirname/basename refactoring bug. X-Git-Tag: 5.1.3~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d982e38b8b2cdb83cb9201a9f7de2d60eb436f2d;p=thirdparty%2Fstrongswan.git Fixed dirname/basename refactoring bug. Variables used in a database query have to be kept until the end of the enumeration --- diff --git a/src/libpts/pts/pts_database.c b/src/libpts/pts/pts_database.c index 07e8ae1dac..fda644a6ab 100644 --- a/src/libpts/pts/pts_database.c +++ b/src/libpts/pts/pts_database.c @@ -280,20 +280,17 @@ METHOD(pts_database_t, check_file_measurement, status_t, DB_TEXT, dir, DB_INT); if (!e) { - free(file); - free(dir); - return FAILED; + status = FAILED; + goto err; } dir_found = e->enumerate(e, &did); e->destroy(e); if (!dir_found) { - free(file); - free(dir); - return NOT_FOUND; + status = NOT_FOUND; + goto err; } - e = this->db->query(this->db, "SELECT fh.hash FROM file_hashes AS fh " "JOIN files AS f ON f.id = fh.file " @@ -302,12 +299,10 @@ METHOD(pts_database_t, check_file_measurement, status_t, DB_TEXT, product, DB_INT, did, DB_TEXT, file, DB_INT, algo, DB_BLOB); } - free(file); - free(dir); - if (!e) { - return FAILED; + status = FAILED; + goto err; } while (e->enumerate(e, &hash)) { @@ -324,6 +319,10 @@ METHOD(pts_database_t, check_file_measurement, status_t, } e->destroy(e); +err: + free(file); + free(dir); + return status; }