]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
genie: Add empty file check to read_token ()
authorAlistair Thomas <astavale@yahoo.co.uk>
Tue, 11 Oct 2016 17:28:35 +0000 (18:28 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 12 Oct 2016 10:43:49 +0000 (12:43 +0200)
Vala.SourceFile uses GLib.MappedFile.get_contents () to read a source
file. This can return null if the file is empty.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=633083
vala/valageniescanner.vala

index e2c5466b54664c26c64f5bddc63344d274f72afd..95a89842d7d9abbe5e5f9cad652aa23d3c42beb7 100644 (file)
@@ -777,7 +777,11 @@ public class Vala.Genie.Scanner {
 
 
        public TokenType read_token (out SourceLocation token_begin, out SourceLocation token_end) {
-               
+               if (current == null) {
+                       token_begin = SourceLocation (current, line, column);
+                       token_end = SourceLocation (current, line, column);
+                       return TokenType.EOF;
+               }
 
                if (in_template ()) {
                        return read_template_token (out token_begin, out token_end);