File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -192,9 +192,11 @@ public enum SyntaxParser {
192
192
swiftparse_parser_set_diagnostic_handler ( c_parser, diagHandler)
193
193
}
194
194
195
- let c_top = swiftparse_parse_string ( c_parser, source)
195
+ let c_top = source. withCString { buf in
196
+ swiftparse_parse_string ( c_parser, buf, source. utf8. count)
197
+ }
196
198
197
- // Get ownership back from the C parser.
199
+ // Get ownership back from the C parser.
198
200
return RawSyntax . moveFromOpaque ( c_top) !
199
201
}
200
202
}
Original file line number Diff line number Diff line change @@ -151,4 +151,10 @@ public class SyntaxTests: XCTestCase {
151
151
let sourceNsString = " var 🎉 = 2 " as NSString
152
152
_ = try ? SyntaxParser . parse ( source: sourceNsString as String )
153
153
}
154
+
155
+ public func testParseFileWithNullCharacter( ) throws {
156
+ let source = " var x = 1 \0 \n var y = 2 "
157
+ let tree = try SyntaxParser . parse ( source: source)
158
+ XCTAssertEqual ( tree. description, source)
159
+ }
154
160
}
You can’t perform that action at this time.
0 commit comments