From e436f2833dc332e3fd728fe6f6b2cd7f224dcf33 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Sun, 1 Mar 2020 12:37:52 +0100 Subject: [PATCH] vala: Report an internal error for unavailable context and bail If calling CodeContext.get/pop() with an empty stack present then there is no way to recover so bail. --- vala/valacodecontext.vala | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala index 1c3ad77cd..88956caf9 100644 --- a/vala/valacodecontext.vala +++ b/vala/valacodecontext.vala @@ -259,6 +259,11 @@ public class Vala.CodeContext { public static CodeContext get () { List* 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* 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); } -- 2.47.2