From 0df6f495e7c6171ca342e832815df8116668cc80 Mon Sep 17 00:00:00 2001 From: Archit Gupta <71798289+archigup@users.noreply.github.com> Date: Fri, 26 May 2023 10:43:50 -0700 Subject: [PATCH] Fix sending empty strings in MQTT packets (#252) 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 ) );