Avoid variable-length arrays in C.

This commit is contained in:
Jake Petroules committed 2014-06-28 21:17:37 -04:00
1 parent 2f16e3f526
commit 8ec5f0ca3c
1 file changed
+4 -2
+4 -2
View File
@@ -47,11 +47,13 @@ NSString *temporaryFilename(NSString *base)
{
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
const char *fsrepr = [template fileSystemRepresentation];
char buffer[strlen(fsrepr)+1];
char *buffer = (char *)malloc(strlen(fsrepr) + 1);
strcpy(buffer, fsrepr);
// mkstemp() can't be used, beause it returns a file descriptor, and XAR API requires a filename
return stringWithFileSystemRepresentation(mktemp(buffer));
NSString *ret = stringWithFileSystemRepresentation(mktemp(buffer));
free(buffer);
return ret;
}
static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t bufferLength)