Skip to content

Commit

Permalink
lseek fd can be bad.
Browse files Browse the repository at this point in the history
Coverity CID 104788
  • Loading branch information
jhi committed Jun 27, 2015
1 parent b66176f commit 511343a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ext/POSIX/POSIX.xs
Expand Up @@ -3210,9 +3210,14 @@ lseek(fd, offset, whence)
Off_t offset
int whence
CODE:
Off_t pos = PerlLIO_lseek(fd, offset, whence);
RETVAL = sizeof(Off_t) > sizeof(IV)
? newSVnv((NV)pos) : newSViv((IV)pos);
if (fd >= 0) {
Off_t pos = PerlLIO_lseek(fd, offset, whence);
RETVAL = sizeof(Off_t) > sizeof(IV)
? newSVnv((NV)pos) : newSViv((IV)pos);
} else {
SETERRNO(EBADF,RMS_IFI);
RETVAL = newSViv(-1);
}
OUTPUT:
RETVAL

Expand Down

0 comments on commit 511343a

Please sign in to comment.