mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use snprintf rather than double strncpy.
This commit is contained in:
parent
e2fe7e4aff
commit
6998246233
1 changed files with 1 additions and 2 deletions
|
@ -766,10 +766,9 @@ get_yjit_stats(rb_execution_context_t *ec, VALUE self)
|
||||||
// where the value is the count of side exits for that instruction.
|
// where the value is the count of side exits for that instruction.
|
||||||
|
|
||||||
char key_string[rb_vm_max_insn_name_size + 6]; // Leave room for "exit_" and a final NUL
|
char key_string[rb_vm_max_insn_name_size + 6]; // Leave room for "exit_" and a final NUL
|
||||||
strncpy(key_string, "exit_", 6); // Copy 6 characters to include the NUL.
|
|
||||||
for (int i = 0; i < VM_INSTRUCTION_SIZE; i++) {
|
for (int i = 0; i < VM_INSTRUCTION_SIZE; i++) {
|
||||||
const char *i_name = insn_name(i); // Look up Ruby's NUL-terminated insn name string
|
const char *i_name = insn_name(i); // Look up Ruby's NUL-terminated insn name string
|
||||||
strncpy(key_string + 5, i_name, rb_vm_max_insn_name_size + 1);
|
snprintf(key_string, rb_vm_max_insn_name_size + 6, "%s%s", "exit_", i_name);
|
||||||
|
|
||||||
VALUE key = ID2SYM(rb_intern(key_string));
|
VALUE key = ID2SYM(rb_intern(key_string));
|
||||||
VALUE value = LL2NUM((long long)exit_op_count[i]);
|
VALUE value = LL2NUM((long long)exit_op_count[i]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue