summaryrefslogtreecommitdiff
path: root/Libraries/LibLine
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-04-02 01:29:48 +0430
committerAndreas Kling <kling@serenityos.org>2020-04-02 08:49:11 +0200
commit8f08ec5038bbee43621af6cd9ef088448d044ee3 (patch)
tree910779ec1596e352797509e14d5843996930849e /Libraries/LibLine
parentcd1d369cdd86b4870d65bc9ad856e8a0850cb4fb (diff)
downloadserenity-8f08ec5038bbee43621af6cd9ef088448d044ee3.zip
LibLine: Restore previous state only if initialized
This makes the library safe to construct/destruct without actually using it.
Diffstat (limited to 'Libraries/LibLine')
-rw-r--r--Libraries/LibLine/Editor.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp
index e5363b148f..83e51aed55 100644
--- a/Libraries/LibLine/Editor.cpp
+++ b/Libraries/LibLine/Editor.cpp
@@ -44,7 +44,8 @@ Editor::Editor()
Editor::~Editor()
{
- tcsetattr(0, TCSANOW, &m_default_termios);
+ if (m_initialized)
+ tcsetattr(0, TCSANOW, &m_default_termios);
}
void Editor::add_to_history(const String& line)