diff options
author | David Robillard <d@drobilla.net> | 2020-07-16 12:01:27 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-07-17 15:42:20 +0200 |
commit | dcc6cd4fbbb5e1f74473a2cf303d832c7dbe54dc (patch) | |
tree | ecb9046c1aa717895c240daff3bf6be68d811b0d /sord | |
parent | 049d5052aaf5033bc5a30ef7c21c8013d9804b58 (diff) | |
download | sord-dcc6cd4fbbb5e1f74473a2cf303d832c7dbe54dc.tar.gz sord-dcc6cd4fbbb5e1f74473a2cf303d832c7dbe54dc.tar.bz2 sord-dcc6cd4fbbb5e1f74473a2cf303d832c7dbe54dc.zip |
Fix potential exception throw in a C context
Diffstat (limited to 'sord')
-rw-r--r-- | sord/sordmm.hpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sord/sordmm.hpp b/sord/sordmm.hpp index 586805d..ef9734e 100644 --- a/sord/sordmm.hpp +++ b/sord/sordmm.hpp @@ -567,12 +567,20 @@ Model::write_to_file(const std::string& uri, SerdSyntax syntax, SerdStyle style) return SERD_SUCCESS; } +extern "C" { + static size_t string_sink(const void* buf, size_t len, void* stream) { - std::string* str = (std::string*)stream; - str->append((const char*)buf, len); - return len; + try { + std::string* str = (std::string*)stream; + str->append((const char*)buf, len); + return len; + } catch (...) { + return 0; + } +} + } inline std::string |