diff --git a/frameworks/src/bundle_test_tool.cpp b/frameworks/src/bundle_test_tool.cpp index 024027743a58901d28440a4ac3c61849ee1056ab..51915987900a776eacd842074e361e447e4c0682 100644 --- a/frameworks/src/bundle_test_tool.cpp +++ b/frameworks/src/bundle_test_tool.cpp @@ -4187,10 +4187,12 @@ ErrCode BundleTestTool::RunAsInstallHmpBundle() uid = option == 'u' ? temp : uid; } - if (counter == 0 && strcmp(argv_[optind], cmd_.c_str()) == 0) { - APP_LOGD("bundle_test_tool getStr with no option."); - resultReceiver_.append(HELP_MSG_NO_INSTALL_HMP_BUNDLE_OPTION); - return OHOS::ERR_INVALID_VALUE; + if (counter == 0) { + if (optind < 0 || optind > argc_ || strcmp(argv_[optind], cmd_.c_str()) == 0) { + APP_LOGD("bundle_test_tool getStr with no option."); + resultReceiver_.append(HELP_MSG_NO_INSTALL_HMP_BUNDLE_OPTION); + return OHOS::ERR_INVALID_VALUE; + } } if (result != OHOS::ERR_OK) {