summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2021-03-19 16:00:49 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2021-03-19 16:00:49 +0100
commit68ef9751c57b408e2199ed3fb739f8c5ad0ee60c (patch)
treec51363a56e788a19256e11f04cecb819ade7c026
parent6e5b14bcb7ee1d81f074f838000e28015cea5ba3 (diff)
downloadvala-68ef9751c57b408e2199ed3fb739f8c5ad0ee60c.tar.gz
girparser: Don't guess length of xml header, iterate forward to <repository>
If e.g. the xml header is missing, it resulted in errors like: error: expected start element of `repository' error: unsupported GIR version (null) (supported: 1.2)
-rw-r--r--vala/valagirparser.vala10
1 files changed, 7 insertions, 3 deletions
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index b1086b893..2345c355e 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1479,10 +1479,14 @@ public class Vala.GirParser : CodeVisitor {
reader = new MarkupReader (source_file.filename);
// xml prolog
- next ();
- next ();
+ do {
+ next ();
+ if (current_token == MarkupTokenType.EOF) {
+ Report.error (get_current_src (), "unexpected end of file");
+ return;
+ }
+ } while (current_token != MarkupTokenType.START_ELEMENT && reader.name != "repository");
- next ();
parse_repository ();
reader = null;