diff --git a/src/object.c b/src/object.c index cb177edbe6..fa14bcb7a2 100644 --- a/src/object.c +++ b/src/object.c @@ -366,7 +366,8 @@ void rt_object_init(struct rt_object *object, /* set object type to static */ object->type = type | RT_Object_Class_Static; /* copy name */ - rt_strncpy(object->name, name, RT_NAME_MAX); + rt_strncpy(object->name, name, RT_NAME_MAX - 1); + object->name[RT_NAME_MAX - 1] = '\0'; RT_OBJECT_HOOK_CALL(rt_object_attach_hook, (object));