File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Sources/SwiftCompilerPluginMessageHandling/JSON Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -591,10 +591,17 @@ extension JSONMapValue {
591
591
/// instantiate 'Swift.String' unless there are escaped characters.
592
592
func equals( to str: String ) -> Bool {
593
593
if self . is ( . simpleString) {
594
- let buffer = valueBuffer ( )
594
+ let lhs = valueBuffer ( )
595
595
var str = str
596
- return str. withUTF8 { utf8 in
597
- utf8. count == buffer. count && memcmp ( utf8. baseAddress, buffer. baseAddress, utf8. count) == 0
596
+ return str. withUTF8 { rhs in
597
+ if lhs. count != rhs. count {
598
+ return false
599
+ }
600
+ guard let lBase = lhs. baseAddress, let rBase = rhs. baseAddress else {
601
+ // If either `baseAddress` is `nil`, both are empty so returns `true`.
602
+ return true
603
+ }
604
+ return memcmp ( lBase, rBase, lhs. count) == 0
598
605
}
599
606
}
600
607
return self . asString ( ) == str
You can’t perform that action at this time.
0 commit comments