From: Rico Tzschichholz Date: Wed, 8 Jul 2020 09:42:02 +0000 (+0200) Subject: Perform runtime version check of libvala X-Git-Tag: 0.51.1~180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbe3e730690176d96078abf0ca1e9756c8d903b2;p=thirdparty%2Fvala.git Perform runtime version check of libvala Fixes https://gitlab.gnome.org/GNOME/vala/issues/88 --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index ad292a777..9a801e369 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -373,6 +373,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { public static int ccode_attribute_cache_index = CodeNode.get_attribute_cache_index (); protected CCodeBaseModule () { + if (Vala.get_build_version () != Vala.BUILD_VERSION) { + Report.error (null, "Integrity check failed (libvala %s doesn't match ccodegen %s)".printf (Vala.get_build_version (), Vala.BUILD_VERSION)); + } + predefined_marshal_set = new HashSet (str_hash, str_equal); predefined_marshal_set.add ("VOID:VOID"); predefined_marshal_set.add ("VOID:BOOLEAN"); diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index e5a6a21d1..4cc7b2967 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -622,6 +622,11 @@ class Vala.Compiler { // initialize locale Intl.setlocale (LocaleCategory.ALL, ""); + if (Vala.get_build_version () != Vala.BUILD_VERSION) { + stderr.printf ("Integrity check failed (libvala %s doesn't match valac %s)\n", Vala.get_build_version (), Vala.BUILD_VERSION); + return 1; + } + if (Path.get_basename (args[0]) == "vala" || Path.get_basename (args[0]) == "vala" + Config.PACKAGE_SUFFIX) { return run_source (args); } diff --git a/valadoc/valadoc.vala b/valadoc/valadoc.vala index 175bbdd9d..68d8b8fa4 100644 --- a/valadoc/valadoc.vala +++ b/valadoc/valadoc.vala @@ -398,6 +398,11 @@ public class ValaDoc : Object { static int main (string[] args) { Intl.setlocale (LocaleCategory.ALL, ""); + if (Vala.get_build_version () != Vala.BUILD_VERSION) { + stderr.printf ("Integrity check failed (libvala %s doesn't match valadoc %s)\n", Vala.get_build_version (), Vala.BUILD_VERSION); + return 1; + } + try { var opt_context = new OptionContext ("- Vala Documentation Tool"); opt_context.set_help_enabled (true); diff --git a/vapigen/valavapigen.vala b/vapigen/valavapigen.vala index 7eb4fc044..7bd37be85 100644 --- a/vapigen/valavapigen.vala +++ b/vapigen/valavapigen.vala @@ -211,6 +211,12 @@ class Vala.VAPIGen { static int main (string[] args) { Intl.setlocale (LocaleCategory.ALL, ""); + + if (Vala.get_build_version () != Vala.BUILD_VERSION) { + stderr.printf ("Integrity check failed (libvala %s doesn't match vapigen %s)\n", Vala.get_build_version (), Vala.BUILD_VERSION); + return 1; + } + try { var opt_context = new OptionContext ("- Vala API Generator"); opt_context.set_help_enabled (true);