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-snort.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-snort.c')
-rw-r--r-- | epan/dissectors/packet-snort.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/epan/dissectors/packet-snort.c b/epan/dissectors/packet-snort.c index 2add440baf..5d9f1efe71 100644 --- a/epan/dissectors/packet-snort.c +++ b/epan/dissectors/packet-snort.c @@ -211,7 +211,7 @@ static void add_alert_to_session_tree(guint frame_number, Alert_t *alert) Alerts_t *alerts = (Alerts_t*)wmem_tree_lookup32(current_session.alerts_tree, frame_number); if (alerts == NULL) { /* Create a new entry for the table */ - alerts = (Alerts_t*)g_malloc(sizeof(Alerts_t)); + alerts = g_new(Alerts_t, 1); /* Deep copy of alert */ alerts->alerts[0] = *alert; alerts->num_alerts = 1; |