]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Avoid fatal handling of nameless unions
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 31 Jan 2016 21:25:16 +0000 (22:25 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 18 Oct 2016 20:39:35 +0000 (22:39 +0200)
vala/valagirparser.vala

index 2e6fa4d920cfa408514fadc485e4208b685416cf..73273f31008082f1e5c17cc3ee973447370405f9 100644 (file)
@@ -3318,7 +3318,33 @@ public class Vala.GirParser : CodeVisitor {
 
        void parse_union () {
                start_element ("union");
-               push_node (element_get_name (), true);
+
+               string? element_name = element_get_name ();
+               if (element_name == null) {
+                       next ();
+
+                       while (current_token == MarkupTokenType.START_ELEMENT) {
+                               if (!push_metadata ()) {
+                                       skip_element ();
+                                       continue;
+                               }
+
+                               if (reader.name == "field") {
+                                       parse_field ();
+                               } else {
+                                       // error
+                                       Report.error (get_current_src (), "unknown child element `%s' in `transparent union'".printf (reader.name));
+                                       skip_element ();
+                               }
+
+                               pop_metadata ();
+                       }
+
+                       end_element ("union");
+                       return;
+               }
+
+               push_node (element_name, true);
 
                Struct st;
                if (current.new_symbol) {