Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Fix issue with double-start of clipboard monitor #121

Merged
merged 2 commits into from
Jan 30, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions source/extensions/extapi/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,9 +1268,20 @@ DWORD request_clipboard_monitor_start(Remote *remote, Packet *packet)
dwResult = ERROR_SUCCESS;
} while (0);

if (dwResult != ERROR_SUCCESS)
if (dwResult == ERROR_ALREADY_INITIALIZED)
{
// if we've already been initialised, then we don't want to go
// resetting gClipboardState back to NULL because that means
// the existing monitor will run indefinitely! Instead we will
// just simulate success here
dwResult = ERROR_SUCCESS;
}
else if (dwResult != ERROR_SUCCESS)
{
destroy_clipboard_monitor_state(pState);
if (pState != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well, but shouldn't we set pState to NULL after freeing it too in destroy_clipboard_monitor_state()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pState is a local variable, so no it's not necessary. Once it's freed and the function exists it's no longer in scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see what you're saying. Sorry, I misunderstood.

Potentially, and that would require the func signature changing. Could be good for the sake of being thorough!

{
destroy_clipboard_monitor_state(pState);
}
gClipboardState = NULL;
}

Expand Down