Skip to content

Commit 55d73e9

Browse files
author
Nathan Hawes
authored
Merge pull request #14355 from nathawes/rdar36077481-crash-in-on-document-update-notification
[sourcekitd] Fix crash in onDocumentUpdateNotification
2 parents 5b4e3f2 + 3d97980 commit 55d73e9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/SourceKit/tools/sourcekitd/bin/XPC/Service/XPCService.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ std::string sourcekitd::getRuntimeLibPath() {
209209
}
210210

211211
static void sourcekitdServer_peer_event_handler(xpc_connection_t peer,
212-
xpc_object_t event) {
212+
xpc_object_t event) {
213213
xpc_type_t type = xpc_get_type(event);
214214
if (type == XPC_TYPE_ERROR) {
215215
if (event == XPC_ERROR_CONNECTION_INVALID) {
@@ -305,6 +305,10 @@ static void sourcekitdServer_event_handler(xpc_connection_t peer) {
305305
sourcekitdServer_peer_event_handler(peer, event);
306306
});
307307

308+
// Update the main connection
309+
xpc_retain(peer);
310+
if (MainConnection)
311+
xpc_release(MainConnection);
308312
MainConnection = peer;
309313

310314
// This will tell the connection to begin listening for events. If you

0 commit comments

Comments
 (0)