From 13918141c7de7acfac434202a5d8d62664c42480 Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Wed, 14 Jun 2017 13:05:54 +0200 Subject: [PATCH] mufs: fix Valgrind warnings in mufs_abspath() by using calloc() instead of malloc() --- source/fs/mufs/dir.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/fs/mufs/dir.c b/source/fs/mufs/dir.c index 8927fd1..1e3cd6c 100644 --- a/source/fs/mufs/dir.c +++ b/source/fs/mufs/dir.c @@ -17,7 +17,10 @@ char *mufs_abspath(const char *path) { char *s, *p, *next, *prev; - if (!(s = malloc(strlen(path) + 2))) + if (!path) + return "/"; + + if (!(s = calloc(strlen(path) + 2, sizeof *s))) return NULL; strcpy(s, path);