Fix a buffer error.

This commit is contained in:
Bill Currie 2011-04-16 13:05:28 +09:00
parent fb65cd2b44
commit 3337dc609f
1 changed files with 5 additions and 2 deletions

View File

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