diff --git a/src/cluster.c b/src/cluster.c index 07cb435..31afae2 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -202,14 +202,12 @@ static void valkeyClusterSetError(valkeyClusterContext *cc, int type, const char *str) { cc->err = type; - /* Copy error string when possible. */ + assert(str != NULL); if (str != NULL && str != cc->errstr) { size_t len = strlen(str); len = len < (sizeof(cc->errstr) - 1) ? len : (sizeof(cc->errstr) - 1); memcpy(cc->errstr, str, len); cc->errstr[len] = '\0'; - } else if (str == NULL) { /* No known usecase. Clear previous errstr. */ - cc->errstr[0] = '\0'; } } @@ -2778,14 +2776,12 @@ static void valkeyClusterAsyncSetError(valkeyClusterAsyncContext *acc, int type, valkeyClusterSetError(acc->cc, type, str); /* Keep error flags identical. */ acc->err = type; - /* Copy error string when possible. */ + assert(str != NULL); if (str != NULL && str != acc->errstr) { size_t len = strlen(str); len = len < (sizeof(acc->errstr) - 1) ? len : (sizeof(acc->errstr) - 1); memcpy(acc->errstr, str, len); acc->errstr[len] = '\0'; - } else if (str == NULL) { /* No known usecase. Clear previous errstr. */ - acc->errstr[0] = '\0'; } }