Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Miracast/MiracastPlayer/Generic/MiracastGstPlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in Miracast/MiracastPlayer/Generic/MiracastGstPlayer.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'Miracast/MiracastPlayer/Generic/MiracastGstPlayer.cpp' (Match: rdkcentral/rdkservices/6.1.7, 409 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: Miracast/MiracastPlayer/Test/SoC_GstPlayer.cpp)

Check failure on line 2 in Miracast/MiracastPlayer/Generic/MiracastGstPlayer.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'Miracast/MiracastPlayer/Generic/MiracastGstPlayer.cpp' (Match: rdkcentral/rdkservices/6.1.7, 1022 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: Miracast/MiracastPlayer/Amlogic/SoC_GstPlayer.cpp)
* following copyright and licenses apply:
*
* Copyright 2023 RDK Management
Expand Down Expand Up @@ -37,7 +37,11 @@
{
if (m_GstPlayer == nullptr)
{
m_GstPlayer = new MiracastGstPlayer();
m_GstPlayer = new (std::nothrow) MiracastGstPlayer();
if (m_GstPlayer == nullptr) {
MIRACASTLOG_ERROR("Failed to allocate MiracastGstPlayer");
return nullptr;
}
}
return m_GstPlayer;
}
Expand Down Expand Up @@ -114,7 +118,7 @@
if (( nullptr != m_video_sink ) && ( 0 < m_video_rect_st.width ) && ( 0 < m_video_rect_st.height ))
{
char rectString[64];
sprintf(rectString,"%d,%d,%d,%d", m_video_rect_st.startX, m_video_rect_st.startY,
snprintf(rectString, sizeof(rectString), "%d,%d,%d,%d", m_video_rect_st.startX, m_video_rect_st.startY,
m_video_rect_st.width, m_video_rect_st.height);
g_object_set(G_OBJECT(m_video_sink), "window-set", rectString, nullptr);
}
Expand Down Expand Up @@ -723,7 +727,7 @@
GstStateChangeReturn ret;
GstBus *bus = nullptr;
bool return_value = true;
m_customQueueHandle = new MessageQueue(500,gstBufferReleaseCallback);
m_customQueueHandle = new (std::nothrow) MessageQueue(500,gstBufferReleaseCallback);
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allocation check for m_customQueueHandle should occur immediately after the allocation on line 730, not at line 732 (which appears to be existing code based on the diff). The error message logged at line 733 needs to be updated to mention the allocation failure specifically.

Copilot uses AI. Check for mistakes.

if (nullptr == m_customQueueHandle)
{
Expand Down
6 changes: 3 additions & 3 deletions Miracast/MiracastPlayer/RTSP/MiracastRTSPMsg.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in Miracast/MiracastPlayer/RTSP/MiracastRTSPMsg.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'Miracast/MiracastPlayer/RTSP/MiracastRTSPMsg.cpp' (Match: rdkcentral/rdkservices/6.1.7, 2378 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: Miracast/MiracastPlayer/RTSP/MiracastRTSPMsg.cpp)
* following copyright and licenses apply:
*
* Copyright 2023 RDK Management
Expand Down Expand Up @@ -359,7 +359,7 @@
// Set the 1st to 3rd bits based on the value of skip_intervals
video_frame_control_support |= ((0x07 & st_video_fmt.st_h264_codecs.max_skip_intervals) << 1); // 1:3 bits for intervals

sprintf( video_format_buffer ,
snprintf(video_format_buffer, sizeof(video_format_buffer),
"%02x %02x %02x %02x %08x %08x %08x %02x %04x %04x %02x ",
st_video_fmt.native,
st_video_fmt.preferred_display_mode_supported,
Expand All @@ -384,7 +384,7 @@
}
else{
memset( video_format_buffer , 0x00 , sizeof(video_format_buffer));
sprintf( video_format_buffer ,
snprintf(video_format_buffer, sizeof(video_format_buffer),
"%04x %04x",
st_video_fmt.st_h264_codecs.max_hres,
st_video_fmt.st_h264_codecs.max_vres );
Expand Down Expand Up @@ -447,7 +447,7 @@
}
memcpy(&m_wfd_audio_formats_st , &st_audio_fmt , sizeof(RTSP_WFD_AUDIO_FMT_STRUCT));

sprintf( audio_format_buffer ,
snprintf(audio_format_buffer, sizeof(audio_format_buffer),
"%s %08x %02x",
audio_format_str.c_str(),
st_audio_fmt.modes,
Expand Down
6 changes: 5 additions & 1 deletion Miracast/MiracastPlayer/Test/MiracastGstPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ MiracastGstPlayer *MiracastGstPlayer::getInstance()
{
if (m_GstPlayer == nullptr)
{
m_GstPlayer = new MiracastGstPlayer();
m_GstPlayer = new (std::nothrow) MiracastGstPlayer();
if (nullptr == m_GstPlayer)
{
MIRACASTLOG_ERROR("Failed to allocate MiracastGstPlayer singleton");
}
}
return m_GstPlayer;
}
Expand Down
50 changes: 29 additions & 21 deletions Miracast/MiracastService/MiracastController.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in Miracast/MiracastService/MiracastController.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'Miracast/MiracastService/MiracastController.cpp' (Match: rdkcentral/rdkservices/6.1.7, 1619 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: Miracast/MiracastService/MiracastController.cpp)
* following copyright and licenses apply:
*
* Copyright 2023 RDK Management
Expand Down Expand Up @@ -28,7 +28,7 @@
MIRACASTLOG_TRACE("Entering...");
if (nullptr == m_miracast_ctrl_obj)
{
m_miracast_ctrl_obj = new MiracastController();
m_miracast_ctrl_obj = new (std::nothrow) MiracastController();
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocation failure is not handled. When new (std::nothrow) returns nullptr, the function should log an error (similar to other allocation checks in this PR) and set an appropriate error code before returning.

Copilot uses AI. Check for mistakes.
if (nullptr != m_miracast_ctrl_obj)
{
m_miracast_ctrl_obj->m_notify_handler = notifier;
Expand Down Expand Up @@ -93,7 +93,7 @@
MiracastError ret_code = MIRACAST_OK;
MIRACASTLOG_TRACE("Entering...");

m_controller_thread = new MiracastThread(CONTROLLER_THREAD_NAME,
m_controller_thread = new (std::nothrow) MiracastThread(CONTROLLER_THREAD_NAME,
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocation failure for m_controller_thread is not checked. After using new (std::nothrow), you should verify that m_controller_thread is not nullptr before proceeding. Add a null check and appropriate error handling.

Copilot uses AI. Check for mistakes.
CONTROLLER_THREAD_STACK,
CONTROLLER_MSGQ_COUNT,
CONTROLLER_MSGQ_SIZE,
Expand Down Expand Up @@ -255,7 +255,7 @@
std::size_t len = 0;
unsigned char retry_count = 5;

sprintf( sys_cls_file_ifidx , "/sys/class/net/%s/ifindex" , interface.c_str());
snprintf(sys_cls_file_ifidx, sizeof(sys_cls_file_ifidx), "/sys/class/net/%s/ifindex", interface.c_str());

std::ifstream ifIndexFile(sys_cls_file_ifidx);

Expand All @@ -264,9 +264,7 @@
return std::string("");
}

sprintf(command, "/sbin/udhcpc -v -i ");
sprintf(command + strlen(command), "%s" , interface.c_str());
sprintf(command + strlen(command), " -s /etc/wifi_p2p/udhcpc.script 2>&1");
snprintf(command, sizeof(command), "/sbin/udhcpc -v -i %s -s /etc/wifi_p2p/udhcpc.script 2>&1", interface.c_str());
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactored snprintf call is missing error handling. While the old code with multiple sprintf calls was unsafe, this single snprintf call should check if the buffer was large enough. Consider checking the return value:

int written = snprintf(command, sizeof(command), "/sbin/udhcpc -v -i %s -s /etc/wifi_p2p/udhcpc.script 2>&1", interface.c_str());
if (written < 0 || written >= sizeof(command)) {
    MIRACASTLOG_ERROR("Failed to format command string");
    return std::string("");
}
Suggested change
snprintf(command, sizeof(command), "/sbin/udhcpc -v -i %s -s /etc/wifi_p2p/udhcpc.script 2>&1", interface.c_str());
int written = snprintf(command, sizeof(command), "/sbin/udhcpc -v -i %s -s /etc/wifi_p2p/udhcpc.script 2>&1", interface.c_str());
if (written < 0 || written >= (int)sizeof(command)) {
MIRACASTLOG_ERROR("Failed to format command string");
return std::string("");
}

Copilot uses AI. Check for mistakes.
MIRACASTLOG_VERBOSE("command : [%s]", command);

while ( retry_count-- )
Expand All @@ -280,20 +278,27 @@
{
MIRACASTLOG_VERBOSE("udhcpc output as below:\n");
memset( data , 0x00 , sizeof(data));
size_t data_len = 0;
while (getline(&current_line_buffer, &len, popen_file_ptr) != -1)
{
sprintf(data + strlen(data), "%s" , current_line_buffer);
size_t remaining = sizeof(data) - data_len - 1;
if (remaining > 0) {
size_t to_copy = strnlen(current_line_buffer, remaining);
memcpy(data + data_len, current_line_buffer, to_copy);
data_len += to_copy;
data[data_len] = '\0';
}
Comment on lines +289 to +290
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The buffer overflow protection silently discards data when the buffer is full. Consider logging a warning when remaining == 0 or when data is truncated, so that developers are aware that output is being lost. Additionally, the logic should break out of the loop once the buffer is full to avoid unnecessary iterations.

Suggested change
data[data_len] = '\0';
}
data[data_len] = '\0';
if (remaining == to_copy) {
// The current line was exactly truncated to fit the buffer, check if next line would overflow
continue;
}
} else {
MIRACASTLOG_WARN("Buffer full while reading udhcpc output, truncating data.");
break;
}
if (data_len >= sizeof(data) - 1) {
MIRACASTLOG_WARN("Buffer full while reading udhcpc output, truncating data.");
break;
}

Copilot uses AI. Check for mistakes.
popen_buffer = data;
MIRACASTLOG_INFO("data : [%s][%s]", data,popen_buffer.c_str());

if ( local_addr.empty() && (std::regex_search(popen_buffer, match, localipRegex)))
if ( local_addr.empty() && (std::regex_search(popen_buffer, match, localipRegex)) && match.size() > 1)
{
local_addr = match[1];
MIRACASTLOG_INFO("local IP addr obtained is %s\n", local_addr.c_str());
}

/* Here retrieved the default gw ip address. Later it can be used as GO IP address if P2P-GROUP started as PERSISTENT */
if ( gw_ip_addr.empty() && (std::regex_search(popen_buffer, match, goipRegex1)))
if ( gw_ip_addr.empty() && (std::regex_search(popen_buffer, match, goipRegex1)) && match.size() > 1)
{
gw_ip_addr = match[1];
MIRACASTLOG_INFO("GO IP addr obtained is %s\n", gw_ip_addr.c_str());
Expand Down Expand Up @@ -648,7 +653,11 @@
// Allocate memory and update the device cache info
if ( nullptr == cur_device_info_ptr )
{
cur_device_info_ptr = new DeviceInfo;
cur_device_info_ptr = new (std::nothrow) DeviceInfo;
if (nullptr == cur_device_info_ptr) {
MIRACASTLOG_ERROR("Failed to allocate DeviceInfo");
return;
}
new_device_entry = true;
force_overwrite = true;
MIRACASTLOG_VERBOSE("#### Creating Device Cache ####");
Expand Down Expand Up @@ -825,20 +834,15 @@

if ( CONTROLLER_GO_DEVICE_LOST == controller_msgq_data.state )
{
size_t found;
int i = 0;

MIRACASTLOG_INFO("CONTROLLER_GO_DEVICE_LOST Received");
for (auto devices : m_deviceInfoList)
for (auto it = m_deviceInfoList.begin(); it != m_deviceInfoList.end(); ++it)
{
found = devices->deviceMAC.find(deviceMAC);
if (found != std::string::npos)
if ((*it)->deviceMAC.find(deviceMAC) != std::string::npos)
{
delete devices;
m_deviceInfoList.erase(m_deviceInfoList.begin() + i);
delete *it;
m_deviceInfoList.erase(it);
break;
}
i++;
}
}
else
Expand Down Expand Up @@ -952,7 +956,11 @@
authType = "pbc",
deviceType = "unknown",
result = "";
m_groupInfo = new GroupInfo;
m_groupInfo = new (std::nothrow) GroupInfo;
if (nullptr == m_groupInfo) {
MIRACASTLOG_ERROR("Failed to allocate GroupInfo");
break;
}
size_t found = event_buffer.find("client");
size_t found_space = event_buffer.find(" ");

Expand Down Expand Up @@ -1045,7 +1053,7 @@
std::string peer_iface_mac = get_SourcePeerIface(mac_address);
char command[128] = {0};
std::string popen_buffer = "";
sprintf( command, "awk '$4 == \"%s\" && $4 !~ /incomplete/ {print $1}' /proc/net/arp", peer_iface_mac.c_str());
snprintf(command, sizeof(command), "awk '$4 == \"%s\" && $4 !~ /incomplete/ {print $1}' /proc/net/arp", peer_iface_mac.c_str());

MiracastCommon::execute_PopenCommand( command , nullptr , 15 , popen_buffer , 1000000 );
if (!popen_buffer.empty())
Expand Down
4 changes: 2 additions & 2 deletions Miracast/MiracastService/MiracastServiceImplementation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check failure on line 1 in Miracast/MiracastService/MiracastServiceImplementation.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'Miracast/MiracastService/MiracastServiceImplementation.cpp' (Match: rdkcentral/rdkservices/6.1.7, 916 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: Miracast/MiracastService/MiracastService.cpp)
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
Expand Down Expand Up @@ -195,7 +195,7 @@

string query = "token=" + token;
Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS)));
m_SystemPluginObj = new WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T(SYSTEM_CALLSIGN_VER), (_T("MiracastService")), false, query);
m_SystemPluginObj = new (std::nothrow) WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T(SYSTEM_CALLSIGN_VER), (_T("MiracastService")), false, query);
if (nullptr == m_SystemPluginObj)
{
MIRACASTLOG_ERROR("JSONRPC: %s: initialization failed", SYSTEM_CALLSIGN_VER);
Expand All @@ -205,7 +205,7 @@
MIRACASTLOG_INFO("JSONRPC: %s: initialization ok", SYSTEM_CALLSIGN_VER);
}

m_WiFiPluginObj = new WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T(WIFI_CALLSIGN_VER), (_T("MiracastService")), false, query);
m_WiFiPluginObj = new (std::nothrow) WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T(WIFI_CALLSIGN_VER), (_T("MiracastService")), false, query);
if (nullptr == m_WiFiPluginObj)
{
MIRACASTLOG_ERROR("JSONRPC: %s: initialization failed", WIFI_CALLSIGN_VER);
Expand Down
6 changes: 5 additions & 1 deletion Miracast/MiracastService/P2P/MiracastP2P.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in Miracast/MiracastService/P2P/MiracastP2P.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'Miracast/MiracastService/P2P/MiracastP2P.cpp' (Match: rdkcentral/rdkservices/6.1.7, 612 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: Miracast/MiracastService/P2P/MiracastP2P.cpp)
* following copyright and licenses apply:
*
* Copyright 2023 RDK Management
Expand Down Expand Up @@ -70,13 +70,17 @@
MIRACASTLOG_TRACE("Entering..");
if (nullptr == m_miracast_p2p_obj)
{
m_miracast_p2p_obj = new MiracastP2P();
m_miracast_p2p_obj = new (std::nothrow) MiracastP2P();
if (nullptr != m_miracast_p2p_obj){
ret_code = m_miracast_p2p_obj->Init(p2p_ctrl_iface);
if ( MIRACAST_OK != ret_code){
destroyInstance();
}
}
else {
MIRACASTLOG_ERROR("Failed to allocate MiracastP2P");
ret_code = MIRACAST_P2P_INIT_FAILED;
}
}
error_code = ret_code;
MIRACASTLOG_TRACE("Exiting..");
Expand Down
9 changes: 8 additions & 1 deletion Miracast/common/MiracastCommon.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in Miracast/common/MiracastCommon.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'Miracast/common/MiracastCommon.cpp' (Match: rdkcentral/rdkservices/6.1.7, 304 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: Miracast/common/MiracastCommon.cpp)
* following copyright and licenses apply:
*
* Copyright 2023 RDK Management
Expand Down Expand Up @@ -250,9 +250,16 @@
}

memset( buffer , 0x00 , sizeof(buffer));
size_t buffer_len = 0;
while (getline(&current_line_buffer, &len, popen_pipe_ptr) != -1)
{
sprintf(buffer + strlen(buffer), "%s" , current_line_buffer);
size_t remaining = sizeof(buffer) - buffer_len - 1;
if (remaining > 0) {
size_t to_copy = strnlen(current_line_buffer, remaining);
memcpy(buffer + buffer_len, current_line_buffer, to_copy);
buffer_len += to_copy;
buffer[buffer_len] = '\0';
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The buffer overflow protection silently discards data when the buffer is full. Consider logging a warning when remaining == 0 or when data is truncated, so that developers are aware that output is being lost. Additionally, the logic should break out of the loop once the buffer is full to avoid unnecessary iterations.

Suggested change
buffer[buffer_len] = '\0';
buffer[buffer_len] = '\0';
if (to_copy == remaining && current_line_buffer[remaining - 1] != '\0' && current_line_buffer[remaining - 1] != '\n') {
MIRACASTLOG_WARN("Buffer full, popen output truncated.");
break;
}
} else {
MIRACASTLOG_WARN("Buffer full, popen output truncated.");
break;

Copilot uses AI. Check for mistakes.
}
MIRACASTLOG_INFO("#### popen Output[%s] ####", buffer);
}
pclose(popen_pipe_ptr);
Expand Down
4 changes: 2 additions & 2 deletions Tests/L1Tests/tests/test_MiracastPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "WrapsMock.h"
#include "WorkerPoolImplementation.h"
#include "MiracastPlayerImplementation.h"
#include <sys/time.h>

Check failure on line 36 in Tests/L1Tests/tests/test_MiracastPlayer.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'Tests/L1Tests/tests/test_MiracastPlayer.cpp' (Match: rdkcentral/rdkservices/6.1.7, 1264 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: Tests/L1Tests/tests/test_MiracastPlayer.cpp)
#include <future>
#include <thread>

Expand Down Expand Up @@ -120,7 +120,7 @@
struct tm *tm_info;
tm_info = localtime(&tv.tv_sec);

sprintf(time_str, ": %02d:%02d:%02d:%06ld", tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, microseconds);
snprintf(time_str, sizeof(time_str), ": %02d:%02d:%02d:%06ld", tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, microseconds);
}

void log( const char *func, const char *file, int line, int threadID,const char *format, ...)
Expand Down Expand Up @@ -413,7 +413,7 @@
TEST_LOG("RTSP_SEND RESPONSE Messages");
if (temp_buffer.find("%s") != std::string::npos)
{
sprintf( buffer , rtsp_req_resp_format , receivedCSeqNum.c_str());
snprintf( buffer, sizeof(buffer), rtsp_req_resp_format , receivedCSeqNum.c_str());
msg_buffer = buffer;
TEST_LOG("Response sequence number replaced as [%s]",receivedCSeqNum.c_str());
receivedCSeqNum.clear();
Expand Down
2 changes: 1 addition & 1 deletion Tests/L1Tests/tests/test_MiracastService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
printf("Entry removed from file: %s\n",fileName);
}

static void createFile(const char* fileName, const char* fileContent)

Check failure on line 92 in Tests/L1Tests/tests/test_MiracastService.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'Tests/L1Tests/tests/test_MiracastService.cpp' (Match: rdkcentral/rdkservices/6.1.7, 42 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/AML_BSP_REL_VERSION_RDK6.1.7.tar.gz, file: Tests/L1Tests/tests/test_MiracastPlayer.cpp)
{
removeFile(fileName);

Expand All @@ -109,7 +109,7 @@
struct tm *tm_info;
tm_info = localtime(&tv.tv_sec);

sprintf(time_str, ": %02d:%02d:%02d:%06ld", tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, microseconds);
snprintf(time_str, sizeof(time_str), ": %02d:%02d:%02d:%06ld", tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, microseconds);
}
void log( const char *func, const char *file, int line, int threadID,const char *format, ...)
{
Expand Down
2 changes: 1 addition & 1 deletion XCast/XCastImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace WPEFramework
if(nullptr == m_SystemPluginObj)
{
Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS)));
m_SystemPluginObj = new WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T(SYSTEM_CALLSIGN_VER), (_T(SYSTEM_CALLSIGN_VER)), false);
m_SystemPluginObj = new (std::nothrow) WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T(SYSTEM_CALLSIGN_VER), (_T(SYSTEM_CALLSIGN_VER)), false);
if (nullptr == m_SystemPluginObj)
{
LOGERR("JSONRPC: [%s]: initialization failed", SYSTEM_CALLSIGN_VER);
Expand Down
21 changes: 18 additions & 3 deletions XCast/XCastManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,22 @@ void XCastManager::registerApplications(std::vector<DynamicAppConfig*>& appConfi
{
LOGINFO("Entering ...");

RegisterAppEntryList *appReqList = new RegisterAppEntryList;
RegisterAppEntryList *appReqList = new (std::nothrow) RegisterAppEntryList;
if (nullptr == appReqList)
{
LOGERR("Failed to allocate RegisterAppEntryList");
return;
}

for (DynamicAppConfig* pDynamicAppConfig : appConfigList)
{
RegisterAppEntry* appReq = new RegisterAppEntry;
RegisterAppEntry* appReq = new (std::nothrow) RegisterAppEntry;
if (nullptr == appReq)
{
LOGERR("Failed to allocate RegisterAppEntry");
delete appReqList;
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When appReq allocation fails, only appReqList is deleted. If RegisterAppEntryList doesn't have a destructor that properly cleans up its entries, the previously allocated RegisterAppEntry objects that were added via pushBack() will leak. Verify that RegisterAppEntryList's destructor properly deallocates all entries, or explicitly iterate through and delete them before deleting the list.

Suggested change
delete appReqList;
// Clean up previously allocated RegisterAppEntry objects
if (appReqList) {
while (!appReqList->empty()) {
RegisterAppEntry* entry = appReqList->front();
appReqList->popFront();
delete entry;
}
delete appReqList;
}

Copilot uses AI. Check for mistakes.
return;
}

appReq->Names = pDynamicAppConfig->appName;
appReq->prefixes = pDynamicAppConfig->prefixes;
Expand Down Expand Up @@ -551,7 +562,11 @@ XCastManager * XCastManager::getInstance()
LOGINFO("Entering ...");
if(XCastManager::_instance == nullptr)
{
XCastManager::_instance = new XCastManager();
XCastManager::_instance = new (std::nothrow) XCastManager();
if (nullptr == XCastManager::_instance)
{
LOGERR("Failed to allocate XCastManager singleton");
}
}
LOGINFO("Exiting ...");
return XCastManager::_instance;
Expand Down
6 changes: 6 additions & 0 deletions helpers/PluginInterfaceBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ namespace Plugin {
public:
PluginInterfaceRef()
: _interface(nullptr)
, _service(nullptr)
{
}

PluginInterfaceRef(INTERFACE* interface, PluginHost::IShell* controller)
: _interface(interface)
, _service(controller)
{
}

Expand All @@ -59,15 +61,19 @@ namespace Plugin {
// use move
PluginInterfaceRef(PluginInterfaceRef&& other)
: _interface(other._interface)
, _service(other._service)
{
other._interface = nullptr;
other._service = nullptr;
}

PluginInterfaceRef& operator=(PluginInterfaceRef&& other)
{
if (this != &other) {
_interface = other._interface;
_service = other._service;
other._interface = nullptr;
other._service = nullptr;
}
return *this;
Comment on lines 70 to 78
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The move assignment operator doesn't properly clean up the existing state before assigning new values. Before assigning other._interface and other._service, you should call Reset() to release the current _interface if it exists, preventing a resource leak.

Copilot uses AI. Check for mistakes.
}
Expand Down
9 changes: 7 additions & 2 deletions helpers/frontpanel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check failure on line 1 in helpers/frontpanel.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'helpers/frontpanel.cpp' (Match: rdkcentral/rdkservices/1, 702 lines, url: https://github.com/rdkcentral/rdkservices/archive/refs/tags/GRT_v1.tar.gz, file: helpers/frontpanel.cpp)
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
Expand Down Expand Up @@ -139,8 +139,13 @@
.withRetryCount(25)
.createInterface();
}
if (!s_instance)
s_instance = new CFrontPanel;
if (!s_instance) {
s_instance = new (std::nothrow) CFrontPanel;
if (!s_instance) {
LOGERR("Failed to allocate CFrontPanel");
return nullptr;
}
}
#ifdef USE_DS
try
{
Expand Down
Loading