added safeguard to ensure that PgfRevision is an actual object

This commit is contained in:
krangelov
2021-09-08 09:17:12 +02:00
parent f741bd9332
commit 2e846cdf59
4 changed files with 35 additions and 17 deletions

View File

@@ -93,6 +93,14 @@ public:
current_db->set_root_internal(root.offset);
}
template<class A>
static ref<A> safe_object2ref(object o) {
if (!current_db->is_valid_object(o, sizeof(A)))
throw pgf_error("Invalid database object");
return o;
}
PGF_INTERNAL_DECL static void sync();
private:
@@ -104,6 +112,8 @@ private:
PGF_INTERNAL_DECL object get_root_internal();
PGF_INTERNAL_DECL void set_root_internal(object root_offset);
PGF_INTERNAL_DECL bool is_valid_object(object o, size_t bytes);
PGF_INTERNAL_DECL unsigned char* relocate(unsigned char* ptr);
friend class DB_scope;