Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -87,11 +87,14 @@ switch ((pid = fork())) { case 0:; OFString **cArray = [arguments cArray]; size_t i, count = [arguments count]; - char **argv = alloca((count + 2) * sizeof(char*)); + char **argv; + + argv = [self allocMemoryForNItems: count + 2 + ofSize: sizeof(char*)]; argv[0] = (char*)[programName cStringWithEncoding: OF_STRING_ENCODING_NATIVE]; for (i = 0; i < count; i++) Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -20,14 +20,10 @@ #include #include #include -#ifdef _WIN32 -# include -#endif - #import "OFString.h" #import "OFString_UTF8.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFFile.h" @@ -1469,37 +1465,42 @@ return new; } - (BOOL)hasPrefix: (OFString*)prefix { - OFAutoreleasePool *pool; of_unichar_t *tmp; const of_unichar_t *prefixString; size_t prefixLength; int compare; if ((prefixLength = [prefix length]) > [self length]) return NO; - tmp = alloca(prefixLength * sizeof(of_unichar_t)); - [self getCharacters: tmp - inRange: of_range(0, prefixLength)]; - - pool = [[OFAutoreleasePool alloc] init]; - - prefixString = [prefix unicodeString]; - compare = memcmp(tmp, prefixString, - prefixLength * sizeof(of_unichar_t)); - - [pool release]; + tmp = [self allocMemoryForNItems: prefixLength + ofSize: sizeof(of_unichar_t)]; + @try { + OFAutoreleasePool *pool; + + [self getCharacters: tmp + inRange: of_range(0, prefixLength)]; + + pool = [[OFAutoreleasePool alloc] init]; + + prefixString = [prefix unicodeString]; + compare = memcmp(tmp, prefixString, + prefixLength * sizeof(of_unichar_t)); + + [pool release]; + } @finally { + [self freeMemory: tmp]; + } return !compare; } - (BOOL)hasSuffix: (OFString*)suffix { - OFAutoreleasePool *pool; of_unichar_t *tmp; const of_unichar_t *suffixString; size_t length, suffixLength; int compare; @@ -1506,21 +1507,29 @@ if ((suffixLength = [suffix length]) > [self length]) return NO; length = [self length]; - tmp = alloca(suffixLength * sizeof(of_unichar_t)); - [self getCharacters: tmp - inRange: of_range(length - suffixLength, suffixLength)]; - - pool = [[OFAutoreleasePool alloc] init]; - - suffixString = [suffix unicodeString]; - compare = memcmp(tmp, suffixString, - suffixLength * sizeof(of_unichar_t)); - - [pool release]; + tmp = [self allocMemoryForNItems: suffixLength + ofSize: sizeof(of_unichar_t)]; + @try { + OFAutoreleasePool *pool; + + [self getCharacters: tmp + inRange: of_range(length - suffixLength, + suffixLength)]; + + pool = [[OFAutoreleasePool alloc] init]; + + suffixString = [suffix unicodeString]; + compare = memcmp(tmp, suffixString, + suffixLength * sizeof(of_unichar_t)); + + [pool release]; + } @finally { + [self freeMemory: tmp]; + } return !compare; } - (OFArray*)componentsSeparatedByString: (OFString*)delimiter