Prevent huge stack allocations for MIDNAM files
xmlParseMemory() uses a c-pointer char*. Previously MIDNAM data on the heap were wrapped inside a std::string only to be later accessed via c_str().
This commit is contained in:
parent
3d166c7789
commit
705ac7bfc5
|
@ -64,8 +64,8 @@ public:
|
|||
|
||||
PBD::Signal0<void> PatchesChanged;
|
||||
|
||||
bool add_custom_midnam (const std::string& id, const std::string& midnam);
|
||||
bool update_custom_midnam (const std::string& id, const std::string& midnam);
|
||||
bool add_custom_midnam (const std::string& id, char const*);
|
||||
bool update_custom_midnam (const std::string& id, char const*);
|
||||
bool remove_custom_midnam (const std::string& id);
|
||||
bool is_custom_model (const std::string& model) const;
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ MidiPatchManager::add_search_path (const Searchpath& search_path)
|
|||
}
|
||||
|
||||
bool
|
||||
MidiPatchManager::add_custom_midnam (const std::string& id, const std::string& midnam)
|
||||
MidiPatchManager::add_custom_midnam (const std::string& id, char const* midnam)
|
||||
{
|
||||
boost::shared_ptr<MIDINameDocument> document;
|
||||
document = boost::shared_ptr<MIDINameDocument>(new MIDINameDocument());
|
||||
|
@ -103,7 +103,7 @@ MidiPatchManager::remove_custom_midnam (const std::string& id)
|
|||
}
|
||||
|
||||
bool
|
||||
MidiPatchManager::update_custom_midnam (const std::string& id, const std::string& midnam)
|
||||
MidiPatchManager::update_custom_midnam (const std::string& id, char const* midnam)
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (_lock);
|
||||
remove_midi_name_document ("custom:" + id, false);
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
bool read(const std::string& fn) { set_filename(fn); return read_internal(false); }
|
||||
bool read_and_validate() { return read_internal(true); }
|
||||
bool read_and_validate(const std::string& fn) { set_filename(fn); return read_internal(true); }
|
||||
bool read_buffer(const std::string&, bool to_tree_doc = false);
|
||||
bool read_buffer(char const*, bool to_tree_doc = false);
|
||||
|
||||
bool write() const;
|
||||
bool write(const std::string& fn) { set_filename(fn); return write(); }
|
||||
|
|
|
@ -124,7 +124,7 @@ XMLTree::read_internal(bool validate)
|
|||
}
|
||||
|
||||
bool
|
||||
XMLTree::read_buffer(const string& buffer, bool to_tree_doc)
|
||||
XMLTree::read_buffer (char const* buffer, bool to_tree_doc)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
|
||||
|
@ -133,7 +133,7 @@ XMLTree::read_buffer(const string& buffer, bool to_tree_doc)
|
|||
delete _root;
|
||||
_root = 0;
|
||||
|
||||
doc = xmlParseMemory(const_cast<char*>(buffer.c_str()), buffer.length());
|
||||
doc = xmlParseMemory (buffer, strlen(buffer));
|
||||
if (!doc) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue