Skip to content

Commit

Permalink
Prevent Segfault in EventPipe on disable (#56104)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Salem authored Jul 27, 2021
1 parent 866808d commit 598c2da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/native/eventpipe/ep-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct _EventPipeProviderCallbackData {
#else
struct _EventPipeProviderCallbackData_Internal {
#endif
const ep_char8_t *filter_data;
ep_char8_t *filter_data;
EventPipeCallback callback_function;
void *callback_data;
int64_t keywords;
Expand Down
11 changes: 8 additions & 3 deletions src/native/eventpipe/ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@ ep_provider_callback_data_alloc_copy (EventPipeProviderCallbackData *provider_ca
EventPipeProviderCallbackData *instance = ep_rt_object_alloc (EventPipeProviderCallbackData);
ep_raise_error_if_nok (instance != NULL);

if (provider_callback_data_src)
if (provider_callback_data_src) {
*instance = *provider_callback_data_src;
instance->filter_data = ep_rt_utf8_string_dup (provider_callback_data_src->filter_data);
}

ep_on_exit:
return instance;
Expand All @@ -270,7 +272,7 @@ ep_provider_callback_data_init (
{
EP_ASSERT (provider_callback_data != NULL);

provider_callback_data->filter_data = filter_data;
provider_callback_data->filter_data = ep_rt_utf8_string_dup (filter_data);
provider_callback_data->callback_function = callback_function;
provider_callback_data->callback_data = callback_data;
provider_callback_data->keywords = keywords;
Expand All @@ -289,19 +291,22 @@ ep_provider_callback_data_init_copy (
EP_ASSERT (provider_callback_data_src != NULL);

*provider_callback_data_dst = *provider_callback_data_src;
provider_callback_data_dst->filter_data = ep_rt_utf8_string_dup (provider_callback_data_src->filter_data);
return provider_callback_data_dst;
}

void
ep_provider_callback_data_fini (EventPipeProviderCallbackData *provider_callback_data)
{
;
ep_return_void_if_nok (provider_callback_data != NULL);
ep_rt_utf8_string_free (provider_callback_data->filter_data);
}

void
ep_provider_callback_data_free (EventPipeProviderCallbackData *provider_callback_data)
{
ep_return_void_if_nok (provider_callback_data != NULL);
ep_provider_callback_data_fini (provider_callback_data);
ep_rt_object_free (provider_callback_data);
}

Expand Down

0 comments on commit 598c2da

Please sign in to comment.