Remove all use of strcpy as we already know the length.

SVN revision: 34617
This commit is contained in:
Cedric BAIL 2008-05-19 15:25:46 +00:00
parent 6226ef6b93
commit 09e1b5d7da
2 changed files with 8 additions and 5 deletions

View File

@ -417,7 +417,7 @@ eet_data_put_string(Eet_Dictionary *ed, const void *src, int *size_ret)
len = strlen(s); len = strlen(s);
d = malloc(len + 1); d = malloc(len + 1);
if (!d) return NULL; if (!d) return NULL;
strcpy(d, s); memcpy(d, s, len + 1);
*size_ret = len + 1; *size_ret = len + 1;
return d; return d;
} }
@ -526,7 +526,7 @@ eet_data_put_float(Eet_Dictionary *ed, const void *src, int *size_ret)
len = strlen(buf); len = strlen(buf);
d = malloc(len + 1); d = malloc(len + 1);
if (!d) return NULL; if (!d) return NULL;
strcpy(d, buf); memcpy(d, buf, len + 1);
*size_ret = len + 1; *size_ret = len + 1;
return d; return d;
} }
@ -589,7 +589,7 @@ eet_data_put_double(Eet_Dictionary *ed, const void *src, int *size_ret)
len = strlen(buf); len = strlen(buf);
d = malloc(len + 1); d = malloc(len + 1);
if (!d) return NULL; if (!d) return NULL;
strcpy(d, buf); memcpy(d, buf, len + 1);
*size_ret = len + 1; *size_ret = len + 1;
return d; return d;

View File

@ -1134,6 +1134,7 @@ eet_open(const char *file, Eet_File_Mode mode)
{ {
FILE *fp; FILE *fp;
Eet_File *ef; Eet_File *ef;
int file_len;
struct stat file_stat; struct stat file_stat;
if (!file) if (!file)
@ -1214,8 +1215,10 @@ eet_open(const char *file, Eet_File_Mode mode)
return ef; return ef;
} }
file_len = strlen(file) + 1;
/* Allocate struct for eet file and have it zero'd out */ /* Allocate struct for eet file and have it zero'd out */
ef = malloc(sizeof(Eet_File) + strlen(file) + 1); ef = malloc(sizeof(Eet_File) + file_len);
if (!ef) if (!ef)
return NULL; return NULL;
@ -1223,7 +1226,7 @@ eet_open(const char *file, Eet_File_Mode mode)
ef->fp = fp; ef->fp = fp;
ef->readfp = NULL; ef->readfp = NULL;
ef->path = ((char *)ef) + sizeof(Eet_File); ef->path = ((char *)ef) + sizeof(Eet_File);
strcpy(ef->path, file); memcpy(ef->path, file, file_len);
ef->magic = EET_MAGIC_FILE; ef->magic = EET_MAGIC_FILE;
ef->references = 1; ef->references = 1;
ef->mode = mode; ef->mode = mode;