Skip to content

Commit

Permalink
Some dereferencing fixes
Browse files Browse the repository at this point in the history
- set darktable.lib to NULL after free
- avoid dereferencing for dt_view_manager_get_current_view() and dt_dev_gui_module()
  • Loading branch information
jenshannoschwalm committed Dec 14, 2024
1 parent 586ba93 commit e1ced0b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,7 @@ void dt_cleanup()

dt_lib_cleanup(darktable.lib);
free(darktable.lib);
darktable.lib = NULL;
}
#ifdef USE_LUA
dt_lua_finalize();
Expand Down
2 changes: 1 addition & 1 deletion src/develop/develop.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ void dt_dev_init_chroma(dt_develop_t *dev);
void dt_dev_clear_chroma_troubles(dt_develop_t *dev);
static inline struct dt_iop_module_t *dt_dev_gui_module(void)
{
return darktable.develop ? darktable.develop->gui_module : NULL;
return (darktable.develop && darktable.gui) ? darktable.develop->gui_module : NULL;
}

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/views/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void dt_view_manager_cleanup(dt_view_manager_t *vm)

const dt_view_t *dt_view_manager_get_current_view(dt_view_manager_t *vm)
{
return vm->current_view;
return vm ? vm->current_view : DT_VIEW_NONE;
}

// we want a stable order of views, for example for viewswitcher.
Expand Down

0 comments on commit e1ced0b

Please sign in to comment.