From 9fd39f8c5150620c2e534fc32a4aa2c09c5c9abc Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Tue, 21 Jul 2009 23:37:24 +0000 Subject: Never try to init a string with a zero pointer; fixes QPID-1998 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@796581 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/windows/SystemInfo.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/sys/windows/SystemInfo.cpp b/cpp/src/qpid/sys/windows/SystemInfo.cpp index 3e2fcb1517..ea53fc199c 100755 --- a/cpp/src/qpid/sys/windows/SystemInfo.cpp +++ b/cpp/src/qpid/sys/windows/SystemInfo.cpp @@ -181,18 +181,21 @@ uint32_t SystemInfo::getParentProcessId() std::string SystemInfo::getProcessName() { + std::string name; + // Only want info for the current process, so ask for something specific. // The module info won't be used here but it keeps the snapshot limited to // the current process so a search through all processes is not needed. HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0); if (snap == INVALID_HANDLE_VALUE) - return 0; + return name; PROCESSENTRY32 entry; entry.dwSize = sizeof(entry); if (!Process32First(snap, &entry)) entry.szExeFile[0] = '\0'; CloseHandle(snap); - return std::string(entry.szExeFile); + name = entry.szExeFile; + return name; } }} // namespace qpid::sys -- cgit v1.2.1