diff --git a/lib/util_mosq.c b/lib/util_mosq.c index 23cc910a..58fb5dfc 100644 --- a/lib/util_mosq.c +++ b/lib/util_mosq.c @@ -160,6 +160,9 @@ int mosquitto__hex2bin_sha1(const char *hex, unsigned char **bin) } sha = mosquitto__malloc(SHA_DIGEST_LENGTH); + if(!sha){ + return MOSQ_ERR_NOMEM; + } memcpy(sha, tmp, SHA_DIGEST_LENGTH); *bin = sha; return MOSQ_ERR_SUCCESS; @@ -379,4 +382,3 @@ enum mosquitto_client_state mosquitto__get_state(struct mosquitto *mosq) return state; } -