[vala/0.50] girparser: Handle empty "<type/>" element and report an error



commit 806373a21d46f8d5520bcc251b0104dde92abb24
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Mar 15 16:02:29 2021 +0100

    girparser: Handle empty "<type/>" element and report an error

 vala/valagirparser.vala | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 02bc640ea..34a74e252 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -2748,7 +2748,16 @@ public class Vala.GirParser : CodeVisitor {
                        type_name = ctype;
                }
 
-               DataType type = parse_type_from_gir_name (type_name, out no_array_length, out 
array_null_terminated, ctype);
+               DataType type;
+               if (type_name != null) {
+                       type = parse_type_from_gir_name (type_name, out no_array_length, out 
array_null_terminated, ctype);
+               } else {
+                       // empty <type/>
+                       no_array_length = false;
+                       array_null_terminated = false;
+                       type = new InvalidType ();
+                       Report.error (get_current_src (), "empty type element");
+               }
 
                // type arguments / element types
                while (current_token == MarkupTokenType.START_ELEMENT) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]