in sem_open, don't leak vm mapping if fstat fails
fstat should not fail under normal circumstances, so this fix is mostly theoretical.
This commit is contained in:
parent
21088aee2e
commit
52d4444f8e
1 changed files with 2 additions and 2 deletions
|
|
@ -82,8 +82,8 @@ sem_t *sem_open(const char *name, int flags, ...)
|
||||||
if (flags != (O_CREAT|O_EXCL)) {
|
if (flags != (O_CREAT|O_EXCL)) {
|
||||||
fd = open(name, FLAGS);
|
fd = open(name, FLAGS);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
if ((map = mmap(0, sizeof(sem_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED ||
|
if (fstat(fd, &st) < 0 ||
|
||||||
fstat(fd, &st) < 0) {
|
(map = mmap(0, sizeof(sem_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
|
||||||
close(fd);
|
close(fd);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue