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



commit 3130c4a0c2c85ce4b30f269132957445928dd2ce
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 49e2e9e9c..036cf9c69 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -2722,7 +2722,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]