Fix a buffer error.

This commit is contained in:
Bill Currie 2011-04-16 13:05:28 +09:00
parent fb65cd2b44
commit 3337dc609f

View file

@ -175,7 +175,7 @@ scanFile
- (void) scanFile: (NSString *)filename - (void) scanFile: (NSString *)filename
{ {
int size, line; int size, line;
const char *data; char *data;
const char *fname; const char *fname;
id cl; id cl;
int i; int i;
@ -190,7 +190,9 @@ scanFile
if (!contents) if (!contents)
return; return;
size = [contents length]; size = [contents length];
data = (const char *) [contents bytes]; data = malloc (size + 1);
memcpy (data, [contents bytes], size);
data[size] = 0;
line = 1; line = 1;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
@ -204,6 +206,7 @@ scanFile
line++; line++;
} }
} }
free (data);
} }
/* /*