diff --git a/drm/ClearKeyDrmSession.cpp b/drm/ClearKeyDrmSession.cpp index 173c84d..f52ffe2 100644 --- a/drm/ClearKeyDrmSession.cpp +++ b/drm/ClearKeyDrmSession.cpp @@ -217,21 +217,44 @@ DrmData * ClearKeySession::generateKeyRequest(string& destinationURL, uint32_t t cJSON *keyIds = cJSON_CreateArray(); if(keyIds) { - cJSON_AddItemToArray(keyIds, cJSON_CreateString(urlEncodedkeyId)); - cJSON_AddItemToObject(licenseRequest, "kids", keyIds); - cJSON_AddItemToObject(licenseRequest, "type",cJSON_CreateString("temporary")); - char* requestBody = cJSON_PrintUnformatted(licenseRequest); - if(requestBody) + cJSON *keyIdItem = cJSON_CreateString(urlEncodedkeyId); + + if (!keyIdItem || !cJSON_AddItemToArray(keyIds, keyIdItem)) + { + MW_LOG_ERR("Failed to add keyId to array"); + if(keyIdItem) cJSON_Delete(keyIdItem); + cJSON_Delete(keyIds); + } + else if (!cJSON_AddItemToObject(licenseRequest, "kids", keyIds)) + { + MW_LOG_ERR("Failed to add kids to license request"); + cJSON_Delete(keyIds); + } + else + { + cJSON *typeItem = cJSON_CreateString("temporary"); + + if (!typeItem || !cJSON_AddItemToObject(licenseRequest, "type", typeItem)) { - MW_LOG_INFO("Generated license request : %s", requestBody); - licenseChallenge = new DrmData( requestBody, strlen(requestBody)); //CID:154682 - overrun - m_eKeyState = KEY_PENDING; - cJSON_free(requestBody); + MW_LOG_ERR("Failed to add type to license request"); + if(typeItem) cJSON_Delete(typeItem); + } + else + { + char* requestBody = cJSON_PrintUnformatted(licenseRequest); + if(requestBody) + { + MW_LOG_INFO("Generated license request : %s", requestBody); + licenseChallenge = new DrmData( requestBody, strlen(requestBody)); //CID:154682 - overrun + m_eKeyState = KEY_PENDING; + cJSON_free(requestBody); + } } } - cJSON_Delete(licenseRequest); } - free(urlEncodedkeyId); + cJSON_Delete(licenseRequest); + } + free(urlEncodedkeyId); } } return licenseChallenge; diff --git a/externals/contentsecuritymanager/SecManagerThunder.cpp b/externals/contentsecuritymanager/SecManagerThunder.cpp index ed13d74..2d8252a 100644 --- a/externals/contentsecuritymanager/SecManagerThunder.cpp +++ b/externals/contentsecuritymanager/SecManagerThunder.cpp @@ -229,10 +229,9 @@ bool SecManagerThunder::AcquireLicenseOpenOrUpdate( std::string clientId, std::s * where input data changes e.g. following a call to updatePlaybackSession * the input data to the shared session is updated here*/ newSession = ContentSecurityManagerSession(response["sessionId"].Number(), - ContentSecurityManager::getInputSummaryHash(moneyTraceMetadata, contentMetadata, - contMetaLen, licenseRequest, keySystemId, - mediaUsage, accessToken, isVideoMuted)); - + ContentSecurityManager::getInputSummaryHash(moneyTraceMetadata, contentMetaDataStr.c_str(), + contMetaLen, licenseRequestStr.c_str(), keySystemId, + mediaUsage, accessTokenStr.c_str(), isVideoMuted)); std::string license = response["license"].String(); MW_LOG_TRACE("SecManager obtained license with length: %d and data: %s",license.size(), license.c_str()); if (!license.empty())