mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
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
4 changed files with 7 additions and 7 deletions
|
|
@ -64,8 +64,8 @@ public:
|
||||||
|
|
||||||
PBD::Signal0<void> PatchesChanged;
|
PBD::Signal0<void> PatchesChanged;
|
||||||
|
|
||||||
bool add_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, const std::string& midnam);
|
bool update_custom_midnam (const std::string& id, char const*);
|
||||||
bool remove_custom_midnam (const std::string& id);
|
bool remove_custom_midnam (const std::string& id);
|
||||||
bool is_custom_model (const std::string& model) const;
|
bool is_custom_model (const std::string& model) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ MidiPatchManager::add_search_path (const Searchpath& search_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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;
|
boost::shared_ptr<MIDINameDocument> document;
|
||||||
document = boost::shared_ptr<MIDINameDocument>(new MIDINameDocument());
|
document = boost::shared_ptr<MIDINameDocument>(new MIDINameDocument());
|
||||||
|
|
@ -103,7 +103,7 @@ MidiPatchManager::remove_custom_midnam (const std::string& id)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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);
|
Glib::Threads::Mutex::Lock lm (_lock);
|
||||||
remove_midi_name_document ("custom:" + id, false);
|
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(const std::string& fn) { set_filename(fn); return read_internal(false); }
|
||||||
bool read_and_validate() { return read_internal(true); }
|
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_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;
|
||||||
bool write(const std::string& fn) { set_filename(fn); return write(); }
|
bool write(const std::string& fn) { set_filename(fn); return write(); }
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ XMLTree::read_internal(bool validate)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
XMLTree::read_buffer(const string& buffer, bool to_tree_doc)
|
XMLTree::read_buffer (char const* buffer, bool to_tree_doc)
|
||||||
{
|
{
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ XMLTree::read_buffer(const string& buffer, bool to_tree_doc)
|
||||||
delete _root;
|
delete _root;
|
||||||
_root = 0;
|
_root = 0;
|
||||||
|
|
||||||
doc = xmlParseMemory(const_cast<char*>(buffer.c_str()), buffer.length());
|
doc = xmlParseMemory (buffer, strlen(buffer));
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue