mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 05:29:10 +02:00
Use snprintf instead of deprecated sprintf
When compiling with -fsanitize=address on macOS, the deprecation of sprintf is effective and prevents compiling yjit.c. More details: https://openradar.appspot.com/FB11761475.
This commit is contained in:
parent
79d8a3159f
commit
4cfe5baf3d
1 changed files with 3 additions and 2 deletions
5
yjit.c
5
yjit.c
|
@ -622,8 +622,9 @@ rb_yjit_iseq_inspect(const rb_iseq_t *iseq)
|
|||
const char *path = RSTRING_PTR(rb_iseq_path(iseq));
|
||||
int lineno = iseq->body->location.code_location.beg_pos.lineno;
|
||||
|
||||
char *buf = ZALLOC_N(char, strlen(label) + strlen(path) + num_digits(lineno) + 3);
|
||||
sprintf(buf, "%s@%s:%d", label, path, lineno);
|
||||
const size_t size = strlen(label) + strlen(path) + num_digits(lineno) + 3;
|
||||
char *buf = ZALLOC_N(char, size);
|
||||
snprintf(buf, size, "%s@%s:%d", label, path, lineno);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue