Skip to content

Commit 7b0d743

Browse files
committed
fix: task_sched.cpp中exec_path未截断字符串
1 parent 54dc74e commit 7b0d743

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

task_sched.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ namespace TaskSched
351351
CSimpleXML xml;
352352
xml.LoadXMLContentDirect(std::wstring(xml_buff));
353353
// 获得配置中的执行路径
354-
const std::wstring command_path = xml.GetNode(L"Command", L"Exec");
354+
std::wstring command_path = xml.GetNode(L"Command", L"Exec");
355355
if (path != nullptr)
356356
{
357357
*path = command_path;
@@ -360,7 +360,13 @@ namespace TaskSched
360360
std::wstring exec_path;
361361
exec_path.resize(MAX_PATH);
362362
GetModuleFileName(NULL, exec_path.data(), MAX_PATH);
363+
364+
// 利用const wchat *的构造方法字符串截断'\0'
365+
command_path = std::wstring(command_path.c_str());
366+
exec_path = std::wstring(exec_path.c_str());
367+
363368
command_path_match = (command_path == exec_path);
369+
364370
SysFreeString(xml_buff);
365371
if (SUCCEEDED(hr))
366372
{

0 commit comments

Comments
 (0)