shm: Fix using negative fd 54/280254/1
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 25 Aug 2022 09:28:27 +0000 (18:28 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Fri, 26 Aug 2022 01:19:20 +0000 (10:19 +0900)
Change-Id: Ib241e89b48c3ff338ecd30178a33a7477802ff0b

clients/simple-shm-shell.c

index cbc92da..e0bdcb4 100644 (file)
@@ -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) {