diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-10-24 11:25:44 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-10-24 11:25:44 -0300 |
commit | e5e24ada4f5578ae921539280e4716a41bfd95cc (patch) | |
tree | 8c9f447b9e5623681715f0df777844b64753804b | |
parent | b72f5188856df0abf45e1a707856bb4e4e86153c (diff) | |
download | pahole-e5e24ada4f5578ae921539280e4716a41bfd95cc.tar.gz |
core: Use zalloc() to make the code more robust
Recently we had a problem where it was assumed that a field was
initialized to zeros but the constructor was using malloc(), check
all use and switch cus__new() to zalloc() to prevent such problems.
The other cases are clone() operations, so no sense in zeroing newly
allocated memory since it will be copied from some other similar
struct.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | dwarves.c | 5 |
1 files changed, 1 insertions, 4 deletions
@@ -2586,12 +2586,9 @@ int cus__fprintf_load_files_err(struct cus *cus __maybe_unused, const char *tool struct cus *cus__new(void) { - struct cus *cus = malloc(sizeof(*cus)); + struct cus *cus = zalloc(sizeof(*cus)); if (cus != NULL) { - cus->nr_entries = 0; - cus->priv = NULL; - cus->loader_exit = NULL; INIT_LIST_HEAD(&cus->cus); pthread_mutex_init(&cus->mutex, NULL); } |