From 05ce55414dc6e0406b1adf78551639b93323b5bb Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 16 Jun 2023 15:35:29 +0200 Subject: [PATCH] handle lookup errors when connecting Connect may result in lookup error, which was not handled. Solve this by use a default error handler which returns whatever mosquitto reports. This prevents us from missing errors. --- lua-mosquitto.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua-mosquitto.c b/lua-mosquitto.c index 7f298bd..32e20a8 100644 --- a/lua-mosquitto.c +++ b/lua-mosquitto.c @@ -114,6 +114,13 @@ static int mosq__pstatus(lua_State *L, int mosq_errno) { lua_pushstring(L, strerror(errno)); return 3; break; + + default: + lua_pushnil(L); + lua_pushinteger(L, mosq_errno); + lua_pushstring(L, mosquitto_strerror(mosq_errno)); + return 3; + break; } return 0;