Fixed dirname/basename refactoring bug.
Variables used in a database query have to be kept until the end of the enumeration
This commit is contained in:
@@ -280,20 +280,17 @@ METHOD(pts_database_t, check_file_measurement, status_t,
|
|||||||
DB_TEXT, dir, DB_INT);
|
DB_TEXT, dir, DB_INT);
|
||||||
if (!e)
|
if (!e)
|
||||||
{
|
{
|
||||||
free(file);
|
status = FAILED;
|
||||||
free(dir);
|
goto err;
|
||||||
return FAILED;
|
|
||||||
}
|
}
|
||||||
dir_found = e->enumerate(e, &did);
|
dir_found = e->enumerate(e, &did);
|
||||||
e->destroy(e);
|
e->destroy(e);
|
||||||
|
|
||||||
if (!dir_found)
|
if (!dir_found)
|
||||||
{
|
{
|
||||||
free(file);
|
status = NOT_FOUND;
|
||||||
free(dir);
|
goto err;
|
||||||
return NOT_FOUND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e = this->db->query(this->db,
|
e = this->db->query(this->db,
|
||||||
"SELECT fh.hash FROM file_hashes AS fh "
|
"SELECT fh.hash FROM file_hashes AS fh "
|
||||||
"JOIN files AS f ON f.id = fh.file "
|
"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_TEXT, product, DB_INT, did, DB_TEXT, file, DB_INT, algo,
|
||||||
DB_BLOB);
|
DB_BLOB);
|
||||||
}
|
}
|
||||||
free(file);
|
|
||||||
free(dir);
|
|
||||||
|
|
||||||
if (!e)
|
if (!e)
|
||||||
{
|
{
|
||||||
return FAILED;
|
status = FAILED;
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
while (e->enumerate(e, &hash))
|
while (e->enumerate(e, &hash))
|
||||||
{
|
{
|
||||||
@@ -324,6 +319,10 @@ METHOD(pts_database_t, check_file_measurement, status_t,
|
|||||||
}
|
}
|
||||||
e->destroy(e);
|
e->destroy(e);
|
||||||
|
|
||||||
|
err:
|
||||||
|
free(file);
|
||||||
|
free(dir);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user