summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-07-16 12:01:27 +0200
committerDavid Robillard <d@drobilla.net>2020-07-17 15:42:20 +0200
commitdcc6cd4fbbb5e1f74473a2cf303d832c7dbe54dc (patch)
treeecb9046c1aa717895c240daff3bf6be68d811b0d
parent049d5052aaf5033bc5a30ef7c21c8013d9804b58 (diff)
downloadsord-dcc6cd4fbbb5e1f74473a2cf303d832c7dbe54dc.tar.gz
sord-dcc6cd4fbbb5e1f74473a2cf303d832c7dbe54dc.tar.bz2
sord-dcc6cd4fbbb5e1f74473a2cf303d832c7dbe54dc.zip
Fix potential exception throw in a C context
-rw-r--r--sord/sordmm.hpp14
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