Skip to content

Commit 4915784

Browse files
committed
Don't give negative "file descriptors" to fdopen
Found by clang-tidy clang-analyzer-unix.StdCLibraryFunctions
1 parent a242ddc commit 4915784

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/osmium/io/bzip2_compression.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ namespace osmium {
109109
file_wrapper() noexcept = default;
110110

111111
file_wrapper(const int fd, const char* mode) {
112+
if (fd < 0) {
113+
throw std::system_error{errno, std::system_category(), "file descriptor must be >= 0"};
114+
}
112115
#ifdef _MSC_VER
113116
osmium::detail::disable_invalid_parameter_handler diph;
114117
#endif

0 commit comments

Comments
 (0)