]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
api.c: add return value check for strdup()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 8 Feb 2022 16:44:19 +0000 (09:44 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 8 Feb 2022 16:44:22 +0000 (09:44 -0700)
In function cg_build_path_locked(), check for return value from
strdup(). This fixes, one of the long pending FIXME.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c

index ae4761e53d7b99b4a5fc61582d5c2afd6b4d07db..f47db98aa9788b3cc5614a4dcc8914f5f6bfc773 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -1518,9 +1518,10 @@ char *cg_build_path_locked(const char *name, char *path,
 
                        if (name) {
                                char *tmp;
-                               tmp = strdup(path);
 
-                               /* FIXME: missing OOM check here! */
+                               tmp = strdup(path);
+                               if (tmp == NULL)
+                                       break;
 
                                cg_concat_path(tmp, name, path);
                                free(tmp);