Fixes github.com/clangd/clangd/issues/1216
If the Snippet string is empty, Snippet.front() would trigger a crash.
Move the Snippet->empty() check up a few lines to avoid this. Should not
break any existing behavior.
Differential D134137
[clangd] Return earlier when snippet is empty tom-anders on Sep 18 2022, 8:03 AM. Authored by
Details
Fixes github.com/clangd/clangd/issues/1216 If the Snippet string is empty, Snippet.front() would trigger a crash.
Diff Detail
Event Timeline
Comment Actions It's not surprising that we often don't crash here, the "obvious" lowering of S.front() is *S.data() which is perfectly valid (will be 0 for an empty string). One way to crash on this is to build with libstdc++'s debug iterators, which assert on this. Fedora seems to be building (some of) their packages in this mode, such that they crash but (sometimes?) do not print the assertion message. This was the cause in https://github.com/clangd/vscode-clangd/issues/400. |
Does this test trigger the crash for you when run without the fix?