From e16166a74cca1d66e2c302e257cf94aebb380599 Mon Sep 17 00:00:00 2001 From: Moshe Kaplan Date: Sun, 20 Dec 2020 21:30:28 -0500 Subject: 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. --- epan/dissectors/packet-mac-lte-framed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'epan/dissectors/packet-mac-lte-framed.c') diff --git a/epan/dissectors/packet-mac-lte-framed.c b/epan/dissectors/packet-mac-lte-framed.c index b901add561..0a805513af 100644 --- a/epan/dissectors/packet-mac-lte-framed.c +++ b/epan/dissectors/packet-mac-lte-framed.c @@ -51,7 +51,7 @@ static int dissect_mac_lte_framed(tvbuff_t *tvb, packet_info *pinfo, p_mac_lte_info = (struct mac_lte_info*)p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0); if (p_mac_lte_info == NULL) { /* Allocate new info struct for this frame */ - p_mac_lte_info = (struct mac_lte_info*)wmem_alloc0(wmem_file_scope(), sizeof(struct mac_lte_info)); + p_mac_lte_info = wmem_new0(wmem_file_scope(), struct mac_lte_info); infoAlreadySet = FALSE; } else { -- cgit v1.2.3