Skip to content
This repository was archived by the owner on Jan 26, 2023. It is now read-only.
/ rdk-aamp Public archive

Commit 6a02d47

Browse files
nkader321Paulpandian Mariappan
nkader321
authored and
Paulpandian Mariappan
committed
DELIA-56924 Aampcli crash when run without parameters in device
Reason for change: To prevent crash in runCommand function checked for vector not empty and proceeded dispatchAampcliCommands function call. Test Procedure: To test the aampcli lib in device without giving command line parameter. Risks: Low Change-Id: I63d238e3d0264293f76e7edfa650a30e9fedb27d (cherry picked from commit 868fdfe)
1 parent 8fe614e commit 6a02d47

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

test/aampcli/Aampcli.cpp

+15-8
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void * Aampcli::runCommand( void* args )
148148
{
149149
char cmd[mMaxBufferLength] = {'\0'};
150150
std::vector<std::string> *arguments;
151-
std::vector<std::string> cmds;
151+
std::vector<std::string> cmdVec;
152152
CommandDispatcher l_CommandDispatcher;
153153
Get l_Get;
154154
Set l_Set;
@@ -158,15 +158,17 @@ void * Aampcli::runCommand( void* args )
158158
if( args )
159159
{
160160
arguments = static_cast<std::vector<std::string>*>(args);
161-
cmds = *arguments;
161+
cmdVec = *arguments;
162162

163-
for(auto param : cmds)
163+
if(!cmdVec.empty())
164164
{
165-
snprintf( cmd+strlen(cmd),mMaxBufferLength-strlen(cmd),"%s ", param.c_str());
166-
}
167-
165+
for(auto param : cmdVec)
166+
{
167+
snprintf( cmd+strlen(cmd),mMaxBufferLength-strlen(cmd),"%s ", param.c_str());
168+
}
168169

169-
l_CommandDispatcher.dispatchAampcliCommands(cmd,mAampcli.mSingleton);
170+
l_CommandDispatcher.dispatchAampcliCommands(cmd,mAampcli.mSingleton);
171+
}
170172
}
171173

172174
l_Get.initGetHelpText();
@@ -323,7 +325,12 @@ int main(int argc, char **argv)
323325
f = NULL;
324326
}
325327

326-
std::vector<std::string> arguments(argv + 1, argv + argc);
328+
std::vector<std::string> arguments;
329+
for(int i = 1; i < argc; i++)
330+
{
331+
arguments.push_back(std::string(argv[i]));
332+
}
333+
327334
pthread_t cmdThreadId;
328335
if(pthread_create(&cmdThreadId,NULL,mAampcli.runCommand, (void *) &arguments) != 0)
329336
{

0 commit comments

Comments
 (0)