Variables used in a database query have to be kept until the end of the enumeration
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 "
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))
{
}
e->destroy(e);
+err:
+ free(file);
+ free(dir);
+
return status;
}