diff --git a/lib/hooks/lua.cpp b/lib/hooks/lua.cpp index b0e5e67e1..eddce457c 100644 --- a/lib/hooks/lua.cpp +++ b/lib/hooks/lua.cpp @@ -71,7 +71,8 @@ public: char *buf; - asprintf(&buf, "Lua: %s: %s", msg, lua_tostring(L, -1)); + if (asprintf(&buf, "Lua: %s: %s", msg, lua_tostring(L, -1)) < 0) + return "Lua: could not format error message"; return buf; } diff --git a/lib/nodes/iec60870.cpp b/lib/nodes/iec60870.cpp index f33ad1748..126c145d7 100644 --- a/lib/nodes/iec60870.cpp +++ b/lib/nodes/iec60870.cpp @@ -333,7 +333,7 @@ bool ASDUData::addSampleToASDU(CS101_ASDU &asdu, ASDUData::Sample sample) const } default: - assert(!"unreachable"); + throw RuntimeError { "invalid asdu data type" }; } bool successfully_added = CS101_ASDU_addInformationObject(asdu, io); diff --git a/lib/nodes/iec61850_goose.cpp b/lib/nodes/iec61850_goose.cpp index 39b718b31..2eacabccf 100644 --- a/lib/nodes/iec61850_goose.cpp +++ b/lib/nodes/iec61850_goose.cpp @@ -110,7 +110,7 @@ MmsValue * GooseSignal::toMmsValue() const case MmsType::MMS_FLOAT: return newMmsFloat(signal_data.f, meta.size); default: - assert(!"unreachable"); + throw RuntimeError { "invalid mms type" }; } } @@ -141,7 +141,7 @@ MmsValue * GooseSignal::newMmsInteger(int64_t i, int size) MmsValue_setInt64(mms_integer, static_cast(i)); return mms_integer; default: - assert(!"unreachable"); + throw RuntimeError { "invalid mms integer size" }; } } @@ -160,7 +160,7 @@ MmsValue * GooseSignal::newMmsUnsigned(uint64_t u, int size) MmsValue_setUint32(mms_unsigned, static_cast(u)); return mms_unsigned; default: - assert(!"unreachable"); + throw RuntimeError { "invalid mms integer size" }; } } @@ -172,7 +172,7 @@ MmsValue * GooseSignal::newMmsFloat(double d, int size) case 64: return MmsValue_newDouble(d); default: - assert(!"unreachable"); + throw RuntimeError { "invalid mms float size" }; } } diff --git a/lib/nodes/redis.cpp b/lib/nodes/redis.cpp index 1b33b34ad..8dcfbcb7a 100644 --- a/lib/nodes/redis.cpp +++ b/lib/nodes/redis.cpp @@ -241,6 +241,7 @@ void redis_on_message(NodeCompat *n, const std::string &channel, const std::stri break; default: + pushed = 0; goto out; }