From: Kamalesh Babulal Date: Tue, 8 Feb 2022 16:44:19 +0000 (-0700) Subject: api.c: add return value check for strdup() X-Git-Tag: v3.0~209 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79d96738b9ba73a8d2507b0b2aa251857441414f;p=thirdparty%2Flibcgroup.git api.c: add return value check for strdup() 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 Signed-off-by: Tom Hromatka --- diff --git a/src/api.c b/src/api.c index ae4761e5..f47db98a 100644 --- 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);