Resource leak

Signed-off-by: Donghwa Jeong <dh48.jeong@samsung.com>
This commit is contained in:
Donghwa Jeong 2018-06-11 15:13:58 +09:00
parent 7177e6b155
commit 928388738b
No known key found for this signature in database
GPG Key ID: 0BE2750EE612F372
2 changed files with 0 additions and 14 deletions

View File

@ -216,18 +216,11 @@ int lxc_monitor_open(const char *lxcpath)
if (lxc_monitor_sock_name(lxcpath, &addr) < 0)
return -1;
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
ERROR("Failed to create socket: %s.", strerror(errno));
return -1;
}
len = strlen(&addr.sun_path[1]);
DEBUG("opening monitor socket %s with len %zu", &addr.sun_path[1], len);
if (len >= sizeof(addr.sun_path) - 1) {
errno = ENAMETOOLONG;
ERROR("name of monitor socket too long (%zu bytes): %s", len, strerror(errno));
close(fd);
return -1;
}

View File

@ -342,16 +342,9 @@ static int lxc_monitor_open(const char *lxcpath)
if (lxc_monitor_sock_name(lxcpath, &addr) < 0)
return -1;
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
fprintf(stderr, "Failed to create socket: %s\n", strerror(errno));
return -errno;
}
len = strlen(&addr.sun_path[1]);
if (len >= sizeof(addr.sun_path) - 1) {
errno = ENAMETOOLONG;
close(fd);
fprintf(stderr, "name of monitor socket too long (%zu bytes): %s\n", len, strerror(errno));
return -errno;
}