[vala/0.46] codegen: Check param for null before using it
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] codegen: Check param for null before using it
- Date: Thu, 30 Jul 2020 11:03:08 +0000 (UTC)
commit 4f0046ace6dab775ef0a6ac5e547c35419f36599
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Jul 22 10:16:39 2020 +0200
codegen: Check param for null before using it
Regression of 5490b0b21a4089d803d51c91311430d60d266f7b
This caused criticals like:
vala_get_ccode_array_length: assertion 'node != NULL' failed
See https://gitlab.gnome.org/GNOME/vala/issues/929
codegen/valaccodemethodcallmodule.vala | 2 +-
tests/Makefile.am | 1 +
tests/methods/varargs-ref.vala | 14 ++++++++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index c672faa69..5a72149df 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -871,7 +871,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
// update possible stale _*_size_ variable
if (unary != null && unary.operator == UnaryOperator.REF) {
- if (get_ccode_array_length (param) && param.variable_type is ArrayType
+ if (param != null && get_ccode_array_length (param) && param.variable_type is
ArrayType
&& !((ArrayType) param.variable_type).fixed_length && ((ArrayType)
param.variable_type).rank == 1) {
unowned Symbol? array_var = unary.inner.symbol_reference;
unowned LocalVariable? array_local = array_var as LocalVariable;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 49f2b3a99..1fae4c1bd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -193,6 +193,7 @@ TESTS = \
methods/varargs-delegate-without-target.vala \
methods/varargs-gvalue.vala \
methods/varargs-out.vala \
+ methods/varargs-ref.vala \
methods/varargs-struct.vala \
control-flow/assigned-local-variable.vala \
control-flow/break.vala \
diff --git a/tests/methods/varargs-ref.vala b/tests/methods/varargs-ref.vala
new file mode 100644
index 000000000..9c3f5fa74
--- /dev/null
+++ b/tests/methods/varargs-ref.vala
@@ -0,0 +1,14 @@
+void set_foo_varg (string s, ...) {
+ var args = va_list ();
+ string** ref_s1 = args.arg ();
+ *ref_s1 = "bar";
+ string** ref_s2 = args.arg ();
+ *ref_s2 = "manam";
+}
+
+void main () {
+ unowned string bar = "", manam = "";
+ set_foo_varg ("foo", ref bar, ref manam);
+ assert (bar == "bar");
+ assert (manam == "manam");
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]