Skip to content

Commit

Permalink
Fix sending empty strings in MQTT packets (#252)
Browse files Browse the repository at this point in the history
The assert that checks that non-zero lengths have non-NULL pointers currently also inadvertently checks that zero lengths have NULL pointers.
  • Loading branch information
archigup committed May 26, 2023
1 parent b0acf49 commit 0df6f49
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/core_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down

0 comments on commit 0df6f49

Please sign in to comment.