From: Rico Tzschichholz Date: Sun, 1 Mar 2020 11:37:52 +0000 (+0100) Subject: vala: Report an internal error for unavailable context and bail X-Git-Tag: 0.48.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e436f2833dc332e3fd728fe6f6b2cd7f224dcf33;p=thirdparty%2Fvala.git 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. --- 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); }