aboutsummaryrefslogtreecommitdiff
path: root/Foundation
diff options
context:
space:
mode:
Diffstat (limited to 'Foundation')
-rw-r--r--Foundation/GTMNSFileHandle+UniqueName.m7
1 files changed, 6 insertions, 1 deletions
diff --git a/Foundation/GTMNSFileHandle+UniqueName.m b/Foundation/GTMNSFileHandle+UniqueName.m
index 536e154..d373159 100644
--- a/Foundation/GTMNSFileHandle+UniqueName.m
+++ b/Foundation/GTMNSFileHandle+UniqueName.m
@@ -28,7 +28,12 @@
NSString *extension = [pathTemplate pathExtension];
char *pathTemplateCString = strdup([pathTemplate fileSystemRepresentation]);
if (!pathTemplateCString) return nil;
- int fileDescriptor = mkstemps(pathTemplateCString, (int)[extension length]);
+ int len = (int)[extension length];
+ if (len > 0) {
+ // Suffix length needs to include a period.
+ len++;
+ }
+ int fileDescriptor = mkstemps(pathTemplateCString, len);
if (fileDescriptor == -1) {
free(pathTemplateCString);
return nil;