From 3021110acdf8c93303c29c4f9db3c71e4c6c9363 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 25 Aug 2022 18:28:27 +0900 Subject: [PATCH] shm: Fix using negative fd Change-Id: Ib241e89b48c3ff338ecd30178a33a7477802ff0b --- clients/simple-shm-shell.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clients/simple-shm-shell.c b/clients/simple-shm-shell.c index cbc92da..e0bdcb4 100644 --- a/clients/simple-shm-shell.c +++ b/clients/simple-shm-shell.c @@ -104,8 +104,10 @@ _create_anonymous_file (off_t size) strncat(name, template, PATH_MAX); fd = mkstemp(name); - if (fd >= 0) - unlink(name); + if (fd < 0) + return -1; + + unlink(name); ret = ftruncate(fd, size); if (ret < 0) { -- 2.7.4