Do not depend on the evaluation order of C arguments
The evaluation order of C arguments is unspecified. `RSTRING_LEN(str)` would fails if the conversion to a String by `StringValuePtr` is not done yet. Coverity Scan found this issue.
This commit is contained in:
parent
5d156007f6
commit
6adc69c41c
Notes:
git
2024-12-03 20:43:43 +00:00
@ -827,7 +827,8 @@ rb_fiddle_ptr_read_mem(VALUE klass, VALUE address, VALUE len)
|
||||
static VALUE
|
||||
rb_fiddle_ptr_write_mem(VALUE klass, VALUE addr, VALUE str)
|
||||
{
|
||||
memcpy(NUM2PTR(addr), StringValuePtr(str), RSTRING_LEN(str));
|
||||
const char *ptr = StringValuePtr(str);
|
||||
memcpy(NUM2PTR(addr), ptr, RSTRING_LEN(str));
|
||||
return str;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user