From ae0a26eaa536fbf85e1b4d7e5874aae64e681db1 Mon Sep 17 00:00:00 2001 From: goebish Date: Sat, 2 Jan 2021 23:42:11 +0100 Subject: [PATCH] Fix crash if connection is lost (#1) Following https://github.com/electric-sheep-co/arduino-redis/issues/33#issuecomment-752709624 --- src/connection.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/connection.c b/src/connection.c index 6c754aa..97e5376 100644 --- a/src/connection.c +++ b/src/connection.c @@ -55,7 +55,9 @@ RedisObject_t RedisConnection_getNextObject(RedisConnection_t conn) readBytes = read(conn, &typeChar, sizeof(typeChar)); } while (readBytes == sizeof(typeChar) && (typeChar == -1 || typeChar == '\r' || typeChar == '\n')); - assert(readBytes == sizeof(typeChar)); + // lost connection to server + if(readBytes != sizeof(typeChar)) + return rObj; RedisObjectTypeMap_t *typeMapWalk = RedisConnection_getNextObject__parseMap; for (; typeMapWalk->type != RedisObjectType_InternalError && typeMapWalk->create != NULL; typeMapWalk++)