aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2022-10-24 11:25:44 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-10-24 11:53:30 -0300
commit02d67c51765dfbd5893087da63744c864c7cc9e0 (patch)
tree8345d7b1ffe2e43cf75a3b0d8d17247387e8adb2
parentcd4d2d251e9a7f982be660f62ff9833506dfba10 (diff)
downloadpahole-02d67c51765dfbd5893087da63744c864c7cc9e0.tar.gz
pfunct: 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 the ones allocating structs to zalloc() to prevent such problems if we add extra fields to those structs. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--pfunct.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pfunct.c b/pfunct.c
index f42bdd1e..5d34bc55 100644
--- a/pfunct.c
+++ b/pfunct.c
@@ -53,7 +53,7 @@ struct fn_stats {
static struct fn_stats *fn_stats__new(struct tag *tag, const struct cu *cu)
{
- struct fn_stats *stats = malloc(sizeof(*stats));
+ struct fn_stats *stats = zalloc(sizeof(*stats));
if (stats != NULL) {
const struct function *fn = tag__function(tag);