Skip to content

Commit

Permalink
Fix context not freed when replacing error handlers and import resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanoBilenchi committed Aug 27, 2024
1 parent 555bcbe commit afc4f84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cowl_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ CowlErrorHandler cowl_get_error_handler(void) {
}

void cowl_set_error_handler(CowlErrorHandler handler) {
if (global_error_handler.free) global_error_handler.free(global_error_handler.ctx);
global_error_handler = handler;
}

Expand Down
2 changes: 2 additions & 0 deletions src/cowl_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,13 @@ void cowl_manager_set_writer(CowlManager *manager, CowlWriter writer) {
}

void cowl_manager_set_import_resolver(CowlManager *manager, CowlImportResolver resolver) {
if (manager->resolver.free) manager->resolver.free(manager->resolver.ctx);
if (!resolver.resolve_import) resolver = cowl_import_resolver_default(manager);
manager->resolver = resolver;
}

void cowl_manager_set_error_handler(CowlManager *manager, CowlErrorHandler handler) {
if (manager->handler.free) manager->handler.free(manager->handler.ctx);
manager->handler = handler;
}

Expand Down

0 comments on commit afc4f84

Please sign in to comment.