mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-24 17:28:59 +00:00
Prevent SegFault when FormatMessageW doesn't return a string on Windows.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31537 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b01361f433
commit
9ef94a8e95
2 changed files with 10 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
2010-10-19 Jonathan Gillaspie <jonathan.gillaspie@testplant.com>
|
||||
|
||||
* Source/Additions/NSError+GNUstepBase.m: Prevent SegFault when FormatMessageW doesn't return a
|
||||
string on Windows.
|
||||
|
||||
2010-10-19 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSURL.m (-absoluteURL): Fix test for an absolute URL,
|
||||
|
|
|
@ -114,14 +114,16 @@ strerror_r(int eno, char *buf, int len)
|
|||
NSDictionary *info;
|
||||
#if defined(__MINGW__)
|
||||
LPVOID lpMsgBuf;
|
||||
NSString *message;
|
||||
NSString *message=nil;
|
||||
|
||||
domain = NSOSStatusErrorDomain;
|
||||
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPWSTR) &lpMsgBuf, 0, NULL );
|
||||
message = [NSString stringWithCharacters: lpMsgBuf length: wcslen(lpMsgBuf)];
|
||||
LocalFree(lpMsgBuf);
|
||||
if (lpMsgBuf != NULL) {
|
||||
message = [NSString stringWithCharacters: lpMsgBuf length: wcslen(lpMsgBuf)];
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
info = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
message, NSLocalizedDescriptionKey,
|
||||
nil];
|
||||
|
|
Loading…
Reference in a new issue