[vala/0.40] vala: Report an internal error for unavailable context and bail
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] vala: Report an internal error for unavailable context and bail
- Date: Thu, 5 Mar 2020 18:46:23 +0000 (UTC)
commit 4a62a1fe08d4900a8b625cfff3dfb8db266733f4
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Mar 1 12:37:52 2020 +0100
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 d3955df70..8c3e15c65 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -258,6 +258,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);
}
@@ -280,6 +285,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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]