diff --git a/src/coders/vec3.cpp b/src/coders/vec3.cpp index e00bdd662..119cbed92 100644 --- a/src/coders/vec3.cpp +++ b/src/coders/vec3.cpp @@ -133,6 +133,9 @@ static model::Mesh load_mesh( if (flags == FLAG_ZLIB) { throw std::runtime_error("compression is not supported yet"); } + if (attributeCount <= 0) { + throw std::runtime_error("mesh must have at least one attribute"); + } std::vector attributes; for (int i = 0; i < attributeCount; i++) { attributes.push_back(load_attribute(reader)); diff --git a/src/io/io.cpp b/src/io/io.cpp index 638108587..d550654e4 100644 --- a/src/io/io.cpp +++ b/src/io/io.cpp @@ -152,6 +152,9 @@ std::vector io::read_bytes(const path& filename) { std::string io::read_string(const path& filename) { size_t size; auto bytes = read_bytes(filename, size); + if (bytes == nullptr) { + throw std::runtime_error("could not read file " + filename.string()); + } return std::string((const char*)bytes.get(), size); } diff --git a/src/logic/scripting/lua/libs/libnetwork.cpp b/src/logic/scripting/lua/libs/libnetwork.cpp index 59d50f075..0d48e4a29 100644 --- a/src/logic/scripting/lua/libs/libnetwork.cpp +++ b/src/logic/scripting/lua/libs/libnetwork.cpp @@ -266,8 +266,10 @@ static int l_peek(lua::State* L, network::Network& network) { static int l_available(lua::State* L, network::Network& network) { u64id_t id = lua::tointeger(L, 1); - if (auto connection = network.getConnection(id, false)) { - return lua::pushinteger(L, dynamic_cast(connection)->available()); + if (auto connection = dynamic_cast( + network.getConnection(id, false) + )) { + return lua::pushinteger(L, connection->available()); } return 0;