From 2283753ba1f2269f5cec79d398876fa3494811e7 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Mon, 30 Dec 2013 16:08:03 +0100 Subject: [PATCH] Check id values when GetReportParser and SetReportParser are called --- BTHID.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/BTHID.h b/BTHID.h index 90fbf54f..3e9c0394 100644 --- a/BTHID.h +++ b/BTHID.h @@ -51,11 +51,26 @@ public: /**@}*/ + /** + * Get HIDReportParser. + * @param id ID of parser. + * @return Returns the corresponding HIDReportParser. Returns NULL if id is not valid. + */ HIDReportParser *GetReportParser(uint8_t id) { + if (id >= NUM_PARSERS) + return NULL; return pRptParser[id]; }; + /** + * Set HIDReportParser to be used. + * @param id Id of parser. + * @param prs Pointer to HIDReportParser. + * @return Returns true if the HIDReportParser is set. False otherwise. + */ bool SetReportParser(uint8_t id, HIDReportParser *prs) { + if (id >= NUM_PARSERS) + return false; pRptParser[id] = prs; return true; };