diff options
author | Moshe Kaplan <me@moshekaplan.com> | 2020-12-20 21:30:28 -0500 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2020-12-22 14:56:38 +0000 |
commit | e16166a74cca1d66e2c302e257cf94aebb380599 (patch) | |
tree | 8834b4b8390fca83dd7bc1b4b9e6a7bb276e1d7e /epan/dissectors/packet-giop.c | |
parent | 7b27b444cbd94853b399da770e0dad4b91ef23ac (diff) |
Detect and replace bad allocation patterns
Adds a pre-commit hook for detecting and replacing
occurrences of `g_malloc()` and `wmem_alloc()` with
`g_new()` and `wmem_new()`, to improve the
readability of Wireshark's code, and
occurrences of
`g_malloc(sizeof(struct myobj) * foo)`
with
`g_new(struct myobj, foo)`
to prevent integer overflows
Also fixes all existing occurrences across
the codebase.
Diffstat (limited to 'epan/dissectors/packet-giop.c')
-rw-r--r-- | epan/dissectors/packet-giop.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/epan/dissectors/packet-giop.c b/epan/dissectors/packet-giop.c index 2f211a7d90..0226f97249 100644 --- a/epan/dissectors/packet-giop.c +++ b/epan/dissectors/packet-giop.c @@ -1337,12 +1337,12 @@ void register_giop_user_module(giop_sub_dissector_t *sub, const gchar *name, con ws_debug_printf("giop:register_module: Module sub dissector name is %s \n", name); #endif - new_module_key = (struct giop_module_key *)wmem_alloc(wmem_epan_scope(), sizeof(struct giop_module_key)); + new_module_key = wmem_new(wmem_epan_scope(), struct giop_module_key); new_module_key->module = module; /* save Module or interface name from IDL */ - module_val = (struct giop_module_val *)wmem_alloc(wmem_epan_scope(), sizeof(struct giop_module_val)); + module_val = wmem_new(wmem_epan_scope(), struct giop_module_val); - module_val->subh = (giop_sub_handle_t *)wmem_alloc(wmem_epan_scope(), sizeof (giop_sub_handle_t)); /* init subh */ + module_val->subh = wmem_new(wmem_epan_scope(), giop_sub_handle_t); /* init subh */ module_val->subh->sub_name = name; /* save dissector name */ module_val->subh->sub_fn = sub; /* save subdissector*/ @@ -1615,7 +1615,7 @@ void register_giop_user(giop_sub_dissector_t *sub, const gchar *name, int sub_pr giop_sub_handle_t *subh; - subh = (giop_sub_handle_t *)wmem_alloc(wmem_epan_scope(), sizeof (giop_sub_handle_t)); + subh = wmem_new(wmem_epan_scope(), giop_sub_handle_t); subh->sub_name = name; subh->sub_fn = sub; |