fix bytrace Infinite loop issue

Signed-off-by: wenlong12 <wenlong12@huawei.com>

Signed-off-by: wenlong12 <wenlong12@huawei.com>
This commit is contained in:
wenlong12
2022-02-23 16:01:37 +08:00
parent a619fa060d
commit 711ad817af
2 changed files with 10 additions and 4 deletions
+9 -3
View File
@@ -177,9 +177,15 @@ static string CanonicalizeSpecPath(const char* src)
return "";
}
#else
if (realpath(src, resolvedPath) == nullptr) {
fprintf(stderr, "Error: _fullpath %s failed", src);
return "";
if (access(src, F_OK) == 0) {
if (realpath(src, resolvedPath) == nullptr) {
fprintf(stderr, "Error: _fullpath %s failed", src);
return "";
}
} else {
if (sprintf_s(resolvedPath, PATH_MAX, "%s", src) == -1) {
return "";
}
}
#endif
string res(resolvedPath);
@@ -283,7 +283,7 @@ MyTrace GetTraceResult(const string& checkContent, const vector<string>& list)
regex pattern(checkContent);
smatch match;
Param param {""};
for (unsigned int i = list.size() - 1; i >= 0; i--) {
for (int i = list.size() - 1; i >= 0; i--) {
if (regex_match(list[i], match, pattern)) {
param.m_task = match[TASK];
param.m_tid = match[TID];