Skip to content

Commit bb5cd8e

Browse files
committed
Get rid of strcpy and magic numbers
1 parent 9b40d2b commit bb5cd8e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

gc/default/default.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4392,15 +4392,16 @@ static inline void
43924392
gc_mark_check_t_none(rb_objspace_t *objspace, VALUE obj)
43934393
{
43944394
if (RB_UNLIKELY(RB_TYPE_P(obj, T_NONE))) {
4395-
char obj_info_buf[256];
4396-
rb_raw_obj_info(obj_info_buf, 256, obj);
4395+
enum {info_size = 256};
4396+
char obj_info_buf[info_size];
4397+
rb_raw_obj_info(obj_info_buf, info_size, obj);
43974398

4398-
char parent_obj_info_buf[256];
4399+
char parent_obj_info_buf[info_size];
43994400
if (objspace->rgengc.parent_object == Qfalse) {
4400-
strcpy(parent_obj_info_buf, "(none)");
4401+
strlcpy(parent_obj_info_buf, "(none)", info_size);
44014402
}
44024403
else {
4403-
rb_raw_obj_info(parent_obj_info_buf, 256, objspace->rgengc.parent_object);
4404+
rb_raw_obj_info(parent_obj_info_buf, info_size, objspace->rgengc.parent_object);
44044405
}
44054406

44064407
rb_bug("try to mark T_NONE object (obj: %s, parent: %s)", obj_info_buf, parent_obj_info_buf);

0 commit comments

Comments
 (0)