Skip to content

Commit adbfee1

Browse files
authored
Merge pull request rdkcentral#5803 from dhivyapriyaMurugesan/RDKDEV-1095_HDMICecSource
RDKDEV-1095 - RDKServices : Wpeframework is restarting when an invalid parameter is passed to the HdmiCecSource plugin API
2 parents 875fb4e + b92b862 commit adbfee1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

HdmiCecSource/HdmiCecSource.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,16 +643,21 @@ namespace WPEFramework
643643
}
644644
uint32_t HdmiCecSource::sendRemoteKeyPressWrapper(const JsonObject& parameters, JsonObject& response)
645645
{
646-
returnIfParamNotFound(parameters, "logicalAddress");
646+
returnIfParamNotFound(parameters, "logicalAddress");
647647
returnIfParamNotFound(parameters, "keyCode");
648648
string logicalAddress = parameters["logicalAddress"].String();
649649
string keyCode = parameters["keyCode"].String();
650650
SendKeyInfo keyInfo;
651-
keyInfo.logicalAddr = stoi(logicalAddress);
652-
keyInfo.keyCode = stoi(keyCode);
651+
try {
652+
keyInfo.logicalAddr = stoi(logicalAddress);
653+
keyInfo.keyCode = stoi(keyCode);
654+
} catch (const std::invalid_argument& e) {
655+
std::cerr << "Invalid input: " << e.what() << std::endl;
656+
returnResponse(false);
657+
}
653658
std::unique_lock<std::mutex> lk(m_sendKeyEventMutex);
654659
m_SendKeyQueue.push(keyInfo);
655-
m_sendKeyEventThreadRun = true;
660+
m_sendKeyEventThreadRun = true;
656661
m_sendKeyCV.notify_one();
657662
LOGINFO("Post send key press event to queue size:%d \n",(int)m_SendKeyQueue.size());
658663
returnResponse(true);

0 commit comments

Comments
 (0)