File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
components/bt/host/bluedroid/stack/avrc Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 4848******************************************************************************/
4949static BT_HDR * avrc_vendor_msg (tAVRC_MSG_VENDOR * p_msg )
5050{
51- BT_HDR * p_cmd ;
51+ BT_HDR * p_cmd = NULL ;
5252 UINT8 * p_data ;
5353
54- assert (p_msg != NULL );
54+ /*
55+ A vendor dependent command consists of at least of:
56+ - A BT_HDR, plus
57+ - AVCT_MSG_OFFSET, plus
58+ - 3 bytes for ctype, subunit_type and op_vendor, plus
59+ - 3 bytes for company_id
60+ */
61+ #define AVRC_MIN_VENDOR_CMD_LEN (BT_HDR_SIZE + AVCT_MSG_OFFSET + AVRC_VENDOR_HDR_SIZE)
62+
63+ if (!p_msg ) {
64+ return NULL ;
65+ }
5566
5667#if AVRC_METADATA_INCLUDED == TRUE
57- assert ( AVRC_META_CMD_BUF_SIZE > ( AVRC_MIN_CMD_LEN + p_msg -> vendor_len ));
58- if ((p_cmd = (BT_HDR * ) osi_malloc (AVRC_META_CMD_BUF_SIZE )) != NULL )
68+ if (( AVRC_META_CMD_BUF_SIZE > AVRC_MIN_VENDOR_CMD_LEN + p_msg -> vendor_len ) &&
69+ ((p_cmd = (BT_HDR * ) osi_malloc (AVRC_META_CMD_BUF_SIZE )) != NULL ) )
5970#else
60- assert ( AVRC_CMD_BUF_SIZE > (AVRC_MIN_CMD_LEN + p_msg -> vendor_len ));
61- if ( (p_cmd = (BT_HDR * ) osi_malloc (AVRC_CMD_BUF_SIZE )) != NULL )
71+ if (( AVRC_CMD_BUF_SIZE > (AVRC_MIN_VENDOR_CMD_LEN + p_msg -> vendor_len )) &&
72+ (p_cmd = (BT_HDR * ) osi_malloc (AVRC_CMD_BUF_SIZE )) != NULL )
6273#endif
6374 {
6475 p_cmd -> offset = AVCT_MSG_OFFSET ;
You can’t perform that action at this time.
0 commit comments