Index: src/OFKernelEventObserver_select.m ================================================================== --- src/OFKernelEventObserver_select.m +++ src/OFKernelEventObserver_select.m @@ -61,11 +61,11 @@ - (void)OF_addObjectForReading: (id)object { int fd = [object fileDescriptorForReading]; - if (fd > INT_MAX - 1) + if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; #ifndef _WIN32 if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; @@ -79,11 +79,11 @@ - (void)OF_addObjectForWriting: (id)object { int fd = [object fileDescriptorForWriting]; - if (fd > INT_MAX - 1) + if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; #ifndef _WIN32 if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; @@ -99,11 +99,11 @@ { /* TODO: Adjust _maxFD */ int fd = [object fileDescriptorForReading]; - if (fd >= FD_SETSIZE) + if (fd < 0 || fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; FD_CLR(fd, &_readFDs); } @@ -111,11 +111,11 @@ { /* TODO: Adjust _maxFD */ int fd = [object fileDescriptorForWriting]; - if (fd >= FD_SETSIZE) + if (fd < 0 || fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; FD_CLR(fd, &_writeFDs); } @@ -175,13 +175,14 @@ objects = [_readObjects objects]; count = [_readObjects count]; for (i = 0; i < count; i++) { - int fd = [objects[i] fileDescriptorForReading]; + int fd; pool = objc_autoreleasePoolPush(); + fd = [objects[i] fileDescriptorForReading]; if (FD_ISSET(fd, &readFDs) && [_delegate respondsToSelector: @selector(objectIsReadyForReading:)]) [_delegate objectIsReadyForReading: objects[i]]; @@ -190,17 +191,18 @@ objects = [_writeObjects objects]; count = [_writeObjects count]; for (i = 0; i < count; i++) { - int fd = [objects[i] fileDescriptorForWriting]; + int fd; pool = objc_autoreleasePoolPush(); + fd = [objects[i] fileDescriptorForWriting]; if (FD_ISSET(fd, &writeFDs) && [_delegate respondsToSelector: @selector(objectIsReadyForWriting:)]) [_delegate objectIsReadyForWriting: objects[i]]; objc_autoreleasePoolPop(pool); } } @end