]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: Added checks for NULL when creating an internal dictionary
authorJan Safranek <jsafrane@redhat.com>
Wed, 24 Aug 2011 09:41:41 +0000 (11:41 +0200)
committerJan Safranek <jsafrane@redhat.com>
Mon, 19 Sep 2011 11:27:38 +0000 (13:27 +0200)
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 <jsafrane@redhat.com>
src/api.c

index e0ed696d7875d512e8d7c1b64103c3d4507e1213..207d076c81de239866a940317c8d81446a40f857 100644 (file)
--- 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;
        }