Fixed the leaks in poll and select