From abfabda5f54ac903bc990340a684e14e5e2b68a5 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 12 May 2013 13:57:34 +0200 Subject: glib allocation functions throw std::bad_alloc exceptions now; catch all bad_allocs and convert them to State::Error * will allow some degree of OOM handling * currently does not work since the exception specifications prevent bad_allocs from propagating. exception specification usage must be completely revised --- src/parser.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 8921942..f64b246 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -83,10 +84,16 @@ Execute::step(const gchar *macro, gint stop_pos) #endif try { - if (interface.is_interrupted()) - throw State::Error("Interrupted"); - - State::input(macro[macro_pc]); + /* convert bad_alloc exceptions */ + try { + if (interface.is_interrupted()) + throw State::Error("Interrupted"); + + State::input(macro[macro_pc]); + } catch (std::bad_alloc &alloc) { + throw State::Error("bad_alloc: %s", + alloc.what()); + } } catch (State::Error &error) { error.pos = macro_pc; String::get_coord(macro, error.pos, -- cgit v1.2.3