]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Report an internal error for unavailable context and bail e436f2833dc332e3fd728fe6f6b2cd7f224dcf33
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 1 Mar 2020 11:37:52 +0000 (12:37 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 1 Mar 2020 12:46:54 +0000 (13:46 +0100)
If calling CodeContext.get/pop() with an empty stack present then there is
no way to recover so bail.

vala/valacodecontext.vala

index 1c3ad77cd1e69b19ead5f74551a94029a95c7c4f..88956caf9e7994643085205bb6cf1791d2806b61 100644 (file)
@@ -259,6 +259,11 @@ public class Vala.CodeContext {
        public static CodeContext get () {
                List<CodeContext>* context_stack = context_stack_key.get ();
 
+               if (context_stack == null || context_stack->size == 0) {
+                       Report.error (null, "internal: No context available to get");
+                       assert_not_reached ();
+               }
+
                return context_stack->get (context_stack->size - 1);
        }
 
@@ -281,6 +286,11 @@ public class Vala.CodeContext {
        public static void pop () {
                List<CodeContext>* context_stack = context_stack_key.get ();
 
+               if (context_stack == null || context_stack->size == 0) {
+                       Report.error (null, "internal: No context available to pop");
+                       assert_not_reached ();
+               }
+
                context_stack->remove_at (context_stack->size - 1);
        }