Skip to content

Commit

Permalink
Remove options memory leak during consent setting
Browse files Browse the repository at this point in the history
  • Loading branch information
stima authored and ayx-rsavchenko committed Dec 7, 2023
1 parent 0b17731 commit 3f3abc3
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/sentry_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,29 +292,27 @@ set_user_consent(sentry_user_consent_t new_val)
{
SENTRY_WITH_OPTIONS (options) {
if (sentry__atomic_store((long *)&options->user_consent, new_val)
== new_val) {
// nothing was changed
break; // SENTRY_WITH_OPTIONS
}

if (options->backend && options->backend->user_consent_changed_func) {
options->backend->user_consent_changed_func(options->backend);
}
!= new_val) {
if (options->backend
&& options->backend->user_consent_changed_func) {
options->backend->user_consent_changed_func(options->backend);
}

sentry_path_t *consent_path
= sentry__path_join_str(options->database_path, "user-consent");
switch (new_val) {
case SENTRY_USER_CONSENT_GIVEN:
sentry__path_write_buffer(consent_path, "1\n", 2);
break;
case SENTRY_USER_CONSENT_REVOKED:
sentry__path_write_buffer(consent_path, "0\n", 2);
break;
case SENTRY_USER_CONSENT_UNKNOWN:
sentry__path_remove(consent_path);
break;
sentry_path_t *consent_path
= sentry__path_join_str(options->database_path, "user-consent");
switch (new_val) {
case SENTRY_USER_CONSENT_GIVEN:
sentry__path_write_buffer(consent_path, "1\n", 2);
break;
case SENTRY_USER_CONSENT_REVOKED:
sentry__path_write_buffer(consent_path, "0\n", 2);
break;
case SENTRY_USER_CONSENT_UNKNOWN:
sentry__path_remove(consent_path);
break;
}
sentry__path_free(consent_path);
}
sentry__path_free(consent_path);
}
}

Expand Down

0 comments on commit 3f3abc3

Please sign in to comment.