From 2cc7ea04d3b832d0d1f956029f9acac6c249f572 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 24 Aug 2011 11:41:41 +0200 Subject: [PATCH] libcgroup: Added checks for NULL when creating an internal dictionary Added one check for null when creating an internal dictionary and fixed checking of calloc result. Changelog: - rephrased the commit message Signed-off-by: Jan Safranek --- src/api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api.c b/src/api.c index e0ed696d..207d076c 100644 --- a/src/api.c +++ b/src/api.c @@ -3946,10 +3946,12 @@ int cgroup_get_procs(char *name, char *controller, pid_t **pids, int *size) int cgroup_dictionary_create(struct cgroup_dictionary **dict, int flags) { + if (!dict) + return ECGINVAL; *dict = (struct cgroup_dictionary *) calloc( 1, sizeof(struct cgroup_dictionary)); - if (!dict) { + if (!*dict) { last_errno = errno; return ECGOTHER; } -- 2.47.2