Skip to content

Commit

Permalink
Add check if plugin strcture can be freed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Feb 13, 2024
1 parent 9f177ed commit 0baeb2a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions librz/include/rz_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ typedef struct rz_lib_struct_t {
void *data; ///< pointer to data handled by plugin handler (e.g. RzBinPlugin, RzAsmPlugin, etc.)
const char *version; ///< rizin version this plugin was compiled for
void (*free)(void *data);
bool is_plugin_owned; ///< If true, Rizin must not free this object. If false, Rizin must free it.
} RzLibStruct;

typedef RzLibStruct *(*RzLibStructFunc)(void);
Expand Down
2 changes: 1 addition & 1 deletion librz/util/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ RZ_API bool rz_lib_open(RzLib *lib, RZ_NONNULL const char *file) {
rz_sys_dlclose(handler);
}

if (strf) {
if (strf && !stru->is_plugin_owned) {
free(stru);
}
return res;
Expand Down

0 comments on commit 0baeb2a

Please sign in to comment.