diff --git a/src/runtime/c/pgf/pgf.cxx b/src/runtime/c/pgf/pgf.cxx index 30908c369..0e7f300cf 100644 --- a/src/runtime/c/pgf/pgf.cxx +++ b/src/runtime/c/pgf/pgf.cxx @@ -119,8 +119,8 @@ PgfDB *pgf_read_ngf(const char *fpath, is_new = true; pgf = PgfDB::malloc(master.size+1); pgf->ref_count = 1; - pgf->major_version = 2; - pgf->minor_version = 0; + pgf->major_version = PGF_MAJOR_VERSION; + pgf->minor_version = PGF_MINOR_VERSION; pgf->gflags = 0; pgf->abstract.name = PgfDB::malloc(); pgf->abstract.name->size = 0; diff --git a/src/runtime/c/pgf/pgf.h b/src/runtime/c/pgf/pgf.h index fbb26d187..2710b3c03 100644 --- a/src/runtime/c/pgf/pgf.h +++ b/src/runtime/c/pgf/pgf.h @@ -40,6 +40,9 @@ #include #include +#define PGF_MAJOR_VERSION 2 +#define PGF_MINOR_VERSION 1 + /* A generic structure to store text. The last field is variable length */ typedef struct { size_t size; diff --git a/src/runtime/c/pgf/reader.cxx b/src/runtime/c/pgf/reader.cxx index f69cf9cd7..4d57ac280 100644 --- a/src/runtime/c/pgf/reader.cxx +++ b/src/runtime/c/pgf/reader.cxx @@ -437,6 +437,11 @@ ref PgfReader::read_pgf() pgf->major_version = read_u16be(); pgf->minor_version = read_u16be(); + if (pgf->major_version != PGF_MAJOR_VERSION || + pgf->minor_version != PGF_MINOR_VERSION) { + throw pgf_error("Unsupported format version"); + } + pgf->gflags = read_namespace(&PgfReader::read_flag); read_abstract(ref::from_ptr(&pgf->abstract));