From cb747fecb407fdd1f4e0daaf040c316d906d2150 Mon Sep 17 00:00:00 2001 From: "cyeh%netscape.com" Date: Tue, 2 Mar 1999 00:03:30 +0000 Subject: [PATCH] (really cyeh) fix crashing bug in optimized builds of viewer, but i'm really suprised that this didn't crash more often. per Inside Macintosh: Processes: you must initialize the ProcessInfoRec with the address to a valid FSSpec and at least 32 bytes of memory if you want the name of the process. if you do not want the name of the process, pass in nil into ProcessInfoRec.processName. We were crashing because the value of PIR.processName was uninitialized, and we were copying the name of the application into random memory. --- xpcom/components/nsRepository.cpp | 4 ++++ xpcom/src/nsRepository.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/xpcom/components/nsRepository.cpp b/xpcom/components/nsRepository.cpp index 8f3949d7ffa8..306c4c40d07d 100644 --- a/xpcom/components/nsRepository.cpp +++ b/xpcom/components/nsRepository.cpp @@ -1473,6 +1473,7 @@ nsresult nsRepository::AutoRegister(NSRegistrationInstant when, ProcessSerialNumber psn; ProcessInfoRec pInfo; FSSpec appFSSpec; + FSSpec tempSpec; long theDirID; Str255 name; #endif @@ -1486,6 +1487,9 @@ nsresult nsRepository::AutoRegister(NSRegistrationInstant when, // get info for the the current process to determine the directory its located in if (!(err = GetCurrentProcess(&psn))) { + // initialize ProcessInfoRec before calling GetProcessInformation() or die horribly. + pInfo.processName = nil; + pInfo.processAppSpec = &tempSpec; if (!(err = GetProcessInformation(&psn, &pInfo))) { appFSSpec = *(pInfo.processAppSpec); diff --git a/xpcom/src/nsRepository.cpp b/xpcom/src/nsRepository.cpp index 8f3949d7ffa8..306c4c40d07d 100644 --- a/xpcom/src/nsRepository.cpp +++ b/xpcom/src/nsRepository.cpp @@ -1473,6 +1473,7 @@ nsresult nsRepository::AutoRegister(NSRegistrationInstant when, ProcessSerialNumber psn; ProcessInfoRec pInfo; FSSpec appFSSpec; + FSSpec tempSpec; long theDirID; Str255 name; #endif @@ -1486,6 +1487,9 @@ nsresult nsRepository::AutoRegister(NSRegistrationInstant when, // get info for the the current process to determine the directory its located in if (!(err = GetCurrentProcess(&psn))) { + // initialize ProcessInfoRec before calling GetProcessInformation() or die horribly. + pInfo.processName = nil; + pInfo.processAppSpec = &tempSpec; if (!(err = GetProcessInformation(&psn, &pInfo))) { appFSSpec = *(pInfo.processAppSpec);