Skip to content

Commit 23215b4

Browse files
authored
Add nil checks for name and file in sortDoc
`name` and `file` don't appear to be guaranteed non-nil; because of this, if there are cases where the key is present on one element but not the other, the equality check will fall through to the less-than check and this results in a crash comparing `string` against `nil`. Resolves: #3111
1 parent fa2c778 commit 23215b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

script/cli/doc/export.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ function export.positionOf(rowcol)
7272
end
7373

7474
function export.sortDoc(a,b)
75-
if a.name ~= b.name then
75+
if a.name and b.name and a.name ~= b.name then
7676
return a.name < b.name
7777
end
7878

79-
if a.file ~= b.file then
79+
if a.file and b.file and a.file ~= b.file then
8080
return a.file < b.file
8181
end
8282

0 commit comments

Comments
 (0)