BGP receives NLRI along path attributes from an eBGP peer (RIB-IN-PEER) and stores the NLRI and path attributes (including unrecognized attributes) in BGP RIB-IN. While sending the NLRI out to an iBGP peer (RIB-OUT-PEER), BGP has to advertise all path-attributes(both recognized and un-recognized). These attributes are encoded into the update message one after the other. BGP large-community attributes are encoded (if present) just before encoding un-recognized attribute.
Hence, BGP generates malformed updates whenever unknown attributes are present, irrespective of whether large-community attributes are present or absent in BGP advertisements.