From 00ef5ffa7758e8b5b0d2e9c2e5061d8318a44f1e Mon Sep 17 00:00:00 2001 From: Archit Gupta <71798289+archigup@users.noreply.github.com> Date: Thu, 25 May 2023 15:50:30 -0700 Subject: [PATCH] Fix sending empty strings in MQTT packets The assert that checks that non-zero lengths have non-NULL pointers currently also inadvertently checks that zero lengths have NULL pointers. --- source/core_mqtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core_mqtt.c b/source/core_mqtt.c index 5fd5f1ff1..b625f08d7 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -1866,7 +1866,7 @@ static size_t addEncodedStringToVector( uint8_t serializedLength[ CORE_MQTT_SERI size_t vectorsAdded = 0U; /* When length is non-zero, the string must be non-NULL. */ - assert( ( length != 0U ) == ( string != NULL ) ); + assert( ( length != 0U ) ? ( string != NULL ) : true ); serializedLength[ 0 ] = ( ( uint8_t ) ( ( length ) >> 8 ) ); serializedLength[ 1 ] = ( ( uint8_t ) ( ( length ) & 0x00ffU ) );