diff --git a/source/backend/engine/CarlaEngineOsc.cpp b/source/backend/engine/CarlaEngineOsc.cpp index add256f71..d9af0de2e 100644 --- a/source/backend/engine/CarlaEngineOsc.cpp +++ b/source/backend/engine/CarlaEngineOsc.cpp @@ -116,9 +116,7 @@ void CarlaEngineOsc::idle() const noexcept if (lo_server_recv_noblock(fServerTCP, 0) == 0) break; } - catch(...) { - break; - } + CARLA_SAFE_EXCEPTION_BREAK("OSC idle TCP") } } @@ -130,9 +128,7 @@ void CarlaEngineOsc::idle() const noexcept if (lo_server_recv_noblock(fServerUDP, 0) == 0) break; } - catch(...) { - break; - } + CARLA_SAFE_EXCEPTION_BREAK("OSC idle UDP") } } } @@ -152,10 +148,14 @@ void CarlaEngineOsc::close() noexcept { try { lo_server_del_method(fServerTCP, nullptr, nullptr); - } catch(...) {} + } + CARLA_SAFE_EXCEPTION("lo_server_del_method TCP") + try { lo_server_free(fServerTCP); - } catch(...) {} + } + CARLA_SAFE_EXCEPTION("lo_server_free TCP") + fServerTCP = nullptr; } @@ -163,10 +163,14 @@ void CarlaEngineOsc::close() noexcept { try { lo_server_del_method(fServerUDP, nullptr, nullptr); - } catch(...) {} + } + CARLA_SAFE_EXCEPTION("lo_server_del_method UDP") + try { lo_server_free(fServerUDP); - } catch(...) {} + } + CARLA_SAFE_EXCEPTION("lo_server_free UDP") + fServerUDP = nullptr; } @@ -180,7 +184,7 @@ void CarlaEngineOsc::close() noexcept // ----------------------------------------------------------------------- -static bool isDigit(const char c) +static bool isDigit(const char c) noexcept { return (c >= '0' && c <= '9'); } @@ -210,7 +214,7 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons // Initial path check if (std::strcmp(path, "/register") == 0) { - const lo_address source = lo_message_get_source(msg); + const lo_address source(lo_message_get_source(msg)); return handleMsgRegister(isTCP, argc, argv, types, source); } if (std::strcmp(path, "/unregister") == 0) @@ -286,9 +290,9 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons } // Get method from path, "/Carla/i/method" -> "method" - char method[32]; - carla_zeroChar(method, 32); - std::strncpy(method, path + (nameSize + offset), 31); + char method[32+1]; + method[32] = '\0'; + std::strncpy(method, path + (nameSize + offset), 32); if (method[0] == '\0') { diff --git a/source/backend/engine/CarlaEngineThread.cpp b/source/backend/engine/CarlaEngineThread.cpp index 654f39c23..88ed3c32a 100644 --- a/source/backend/engine/CarlaEngineThread.cpp +++ b/source/backend/engine/CarlaEngineThread.cpp @@ -75,9 +75,7 @@ void CarlaEngineThread::run() noexcept try { plugin->postRtEventsRun(); } - catch (...) { - carla_stderr2("Caught exception during postRtEventsRun()"); - } + CARLA_SAFE_EXCEPTION("postRtEventsRun()") } if (hasUi || oscRegisted) diff --git a/source/includes/CarlaDefines.h b/source/includes/CarlaDefines.h index 9aa196e87..279499f8d 100644 --- a/source/includes/CarlaDefines.h +++ b/source/includes/CarlaDefines.h @@ -148,7 +148,11 @@ #define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); return ret; } /* Define CARLA_SAFE_EXCEPTION */ -#define CARLA_SAFE_EXCEPTION(msg, aftercode) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); aftercode } +#define CARLA_SAFE_EXCEPTION(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); } + +#define CARLA_SAFE_EXCEPTION_BREAK(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); break; } +#define CARLA_SAFE_EXCEPTION_CONTINUE(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); continue; } +#define CARLA_SAFE_EXCEPTION_RETURN(msg, ret) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); return ret; } /* Define CARLA_DECLARE_NON_COPY_CLASS */ #ifdef CARLA_PROPER_CPP11_SUPPORT