mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-10-13 00:40:11 +00:00
change strcpy to strlcpy
Change-Id: I8b9429a3c225a82842fce136bdb14b8b135066d3 Signed-off-by: lilei19 <lilei19@xiaomi.com>
This commit is contained in:
parent
e86745b9a2
commit
41f60bd669
33 changed files with 238 additions and 180 deletions
|
|
@ -289,7 +289,7 @@ int Auto_variable(struct Auto *this, const struct Identifier *ident)
|
|||
|
||||
(*tail) = malloc(sizeof(struct Symbol));
|
||||
(*tail)->next = (struct Symbol *)0;
|
||||
(*tail)->name = strcpy(malloc(strlen(ident->name) + 1), ident->name);
|
||||
(*tail)->name = strdup(ident->name);
|
||||
(*tail)->type = LOCALVAR;
|
||||
(*tail)->u.local.type = ident->defaultType;
|
||||
|
||||
|
|
|
|||
|
|
@ -2000,7 +2000,7 @@ static void builtin(struct Global *this, const char *ident, enum ValueType type,
|
|||
if (*r == (struct Symbol *)0)
|
||||
{
|
||||
*r = malloc(sizeof(struct Symbol));
|
||||
(*r)->name = strcpy(malloc(strlen(ident) + 1), ident);
|
||||
(*r)->name = strdup(ident);
|
||||
(*r)->next = (struct Symbol *)0;
|
||||
s = (*r);
|
||||
}
|
||||
|
|
@ -2223,7 +2223,7 @@ int Global_variable(struct Global *this, struct Identifier *ident,
|
|||
if (*r == (struct Symbol *)0)
|
||||
{
|
||||
*r = malloc(sizeof(struct Symbol));
|
||||
(*r)->name = strcpy(malloc(strlen(ident->name) + 1), ident->name);
|
||||
(*r)->name = strdup(ident->name);
|
||||
(*r)->next = (struct Symbol *)0;
|
||||
(*r)->type = symbolType;
|
||||
Var_new(&((*r)->u.var), type, 0, (unsigned int *)0, 0);
|
||||
|
|
@ -2275,7 +2275,7 @@ int Global_function(struct Global *this, struct Identifier *ident,
|
|||
}
|
||||
|
||||
*r = malloc(sizeof(struct Symbol));
|
||||
(*r)->name = strcpy(malloc(strlen(ident->name) + 1), ident->name);
|
||||
(*r)->name = strdup(ident->name);
|
||||
(*r)->next = (struct Symbol *)0;
|
||||
(*r)->type = USERFUNCTION;
|
||||
(*r)->u.sub.u.def.scope.start = *deffn;
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ struct Value *Value_new_ERROR(struct Value *this, int code, const char *error,
|
|||
va_end(ap);
|
||||
this->type = V_ERROR;
|
||||
this->u.error.code = code;
|
||||
this->u.error.msg = strcpy(malloc(strlen(buf) + 1), buf);
|
||||
this->u.error.msg = strdup(buf);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -364,13 +364,12 @@ struct Value *Value_clone(struct Value *this, const struct Value *original)
|
|||
{
|
||||
assert(this != (struct Value *)0);
|
||||
assert(original != (struct Value *)0);
|
||||
|
||||
switch (original->type)
|
||||
{
|
||||
case V_ERROR:
|
||||
{
|
||||
strcpy(this->u.error.msg =
|
||||
malloc(strlen(original->u.error.msg) + 1),
|
||||
original->u.error.msg);
|
||||
this->u.error.msg = strdup(original->u.error.msg);
|
||||
this->u.error.code = original->u.error.code;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue