summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ScriptInterpreter/Python
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-09-23 20:36:46 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-09-23 20:36:46 +0000
commit948786c9295de3ec8536d8ec6ec7dd45b3f66184 (patch)
tree6a21cfc885ff8e3ff64505912ba50d5591fad516 /lldb/source/Plugins/ScriptInterpreter/Python
parent4750d79ac686861c9d51996611dd8413178396c4 (diff)
downloadbcm5719-llvm-948786c9295de3ec8536d8ec6ec7dd45b3f66184.tar.gz
bcm5719-llvm-948786c9295de3ec8536d8ec6ec7dd45b3f66184.zip
File::SetDescriptor() should require options
lvm_private::File::GetStream() can fail if m_options == 0 It's not clear from the header a File created with a descriptor will be not be usable by many parts of LLDB unless SetOptions is also called, but it is. This is because those parts of LLDB rely on GetStream() to use the file, and that in turn relies on calling fdopen on the descriptor. When calling fdopen, GetStream relies on m_options to determine the access mode. If m_options has never been set, GetStream() will fail. This patch adds options as a required argument to File::SetDescriptor and the corresponding constructor. Patch by: Lawrence D'Anna Differential revision: https://reviews.llvm.org/D67792 llvm-svn: 372652
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 29dd037efd8..97f8388d771 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1043,9 +1043,9 @@ bool PythonFile::GetUnderlyingFile(File &file) const {
file.Close();
// We don't own the file descriptor returned by this function, make sure the
// File object knows about that.
- file.SetDescriptor(PyObject_AsFileDescriptor(m_py_obj), false);
PythonString py_mode = GetAttributeValue("mode").AsType<PythonString>();
- file.SetOptions(PythonFile::GetOptionsFromMode(py_mode.GetString()));
+ auto options = PythonFile::GetOptionsFromMode(py_mode.GetString());
+ file.SetDescriptor(PyObject_AsFileDescriptor(m_py_obj), options, false);
return file.IsValid();
}
OpenPOWER on IntegriCloud