diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2026-06-20 11:09:03 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2026-06-20 11:09:03 +0200 |
| commit | 280190248bfbadaec4575932dc956401f7bb6390 (patch) | |
| tree | 70eb2d797349127e68108f0d1ed58e87ddecd5ea | |
| parent | 1ae9669c30089447212b05104a239c0866890116 (diff) | |
| download | ttwhy-280190248bfbadaec4575932dc956401f7bb6390.tar.xz ttwhy-280190248bfbadaec4575932dc956401f7bb6390.zip | |
lib: harden scoped attributes
| -rw-r--r-- | ttwhy/scoped_attributes.cppm | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ttwhy/scoped_attributes.cppm b/ttwhy/scoped_attributes.cppm index c68ab01..080bca7 100644 --- a/ttwhy/scoped_attributes.cppm +++ b/ttwhy/scoped_attributes.cppm @@ -56,9 +56,15 @@ namespace ttwhy export struct scoped_attributes { explicit scoped_attributes(int file_descriptor) - : m_file_descriptor{::dup(file_descriptor)} - , m_attributes{read_attributes(file_descriptor)} - {} + : m_file_descriptor{-1} + , m_attributes{} + { + if (isatty(file_descriptor)) + { + m_file_descriptor = dup(file_descriptor); + m_attributes = read_attributes(m_file_descriptor); + } + } scoped_attributes(scoped_attributes const &) = delete; |
