open-content-decryption-module-cdmi icon indicating copy to clipboard operation
open-content-decryption-module-cdmi copied to clipboard

map operator usage problem

Open chris0710 opened this issue 8 years ago • 1 comments

In function rpc_open_cdm_mediakeysession_release_1_svc() or rpc_open_cdm_mediakeysession_update_1_svc()

p_mediaKeySession = g_mediaKeySessions[params->session_id.session_id_val];

if (p_mediaKeySession) {

It seems not safty. If params->session_id.session_id_val matches the key of an element in the map, it will return a reference to its mapped value, and it's ok. But, if it does not match the key of any element in the map, it will inserts a new element with that key and returns a reference to its mapped value.

It left some trash element in this map.

reference from http://www.cplusplus.com/reference/map/map/operator[]/

chris0710 avatar Sep 13 '17 07:09 chris0710

I found another bug at rpc_open_cdm_mediakeysession_release_1_svc function g_mediaKeySessions.erase(params->session_id.session_id_val ) did not remove the whole entry from map it left some barbage in map and cause cdmi service crash, you should use iterator item to remove the entry

calais007 avatar Jan 04 '18 11:01 calais007