Add comment to gzdopen() in zlib.h to use dup() when using fileno().
A problem surfaced in a multi-threaded application where fileno() was used to get a file descriptor from an fopen(), which was then fed to gzdopen(). The problem occurred when the gzclose() followed by the fclose() tried to close the same file descriptor twice. If fclose() were not done, there would be a memory leak. The only way out is to dup() the file descriptor so that gzclose() closes the duplicated file descriptor, and fclose() closes the original file descriptor.
Showing
想要评论请 注册 或 登录