[vala/0.48] codegen: Check param for null before using it
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] codegen: Check param for null before using it
- Date: Wed, 22 Jul 2020 11:54:33 +0000 (UTC)
commit a6ad0e162b6d3b06fc7080b41c9279800e1b45de
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 9ffb8deb7..7a6d159b2 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -902,7 +902,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 94ccc2153..79f38e51d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -198,6 +198,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]