Skip to content

Commit 2283753

Browse files
committed
Check id values when GetReportParser and SetReportParser are called
1 parent 8ae6f8b commit 2283753

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

BTHID.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,26 @@ class BTHID : public BluetoothService {
5151

5252
/**@}*/
5353

54+
/**
55+
* Get HIDReportParser.
56+
* @param id ID of parser.
57+
* @return Returns the corresponding HIDReportParser. Returns NULL if id is not valid.
58+
*/
5459
HIDReportParser *GetReportParser(uint8_t id) {
60+
if (id >= NUM_PARSERS)
61+
return NULL;
5562
return pRptParser[id];
5663
};
5764

65+
/**
66+
* Set HIDReportParser to be used.
67+
* @param id Id of parser.
68+
* @param prs Pointer to HIDReportParser.
69+
* @return Returns true if the HIDReportParser is set. False otherwise.
70+
*/
5871
bool SetReportParser(uint8_t id, HIDReportParser *prs) {
72+
if (id >= NUM_PARSERS)
73+
return false;
5974
pRptParser[id] = prs;
6075
return true;
6176
};

0 commit comments

Comments
 (0)