зеркало из https://github.com/github/ruby.git
Make embedded string length a long for VWA
A short (2 bytes) will cause unaligned struct accesses when strings are used as a buffer to directly store binary data.
This commit is contained in:
Родитель
e28dbd0f3d
Коммит
2d81a718ec
|
@ -280,7 +280,7 @@ struct RString {
|
|||
/** Embedded contents. */
|
||||
struct {
|
||||
#if USE_RVARGC
|
||||
unsigned short len;
|
||||
long len;
|
||||
/* This is a length 1 array because:
|
||||
* 1. GCC has a bug that does not optimize C flexible array members
|
||||
* (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452)
|
||||
|
|
|
@ -66,7 +66,7 @@ class Test_StringCapacity < Test::Unit::TestCase
|
|||
|
||||
def embed_header_size
|
||||
if GC.using_rvargc?
|
||||
2 * RbConfig::SIZEOF['void*'] + RbConfig::SIZEOF['short']
|
||||
2 * RbConfig::SIZEOF['void*'] + RbConfig::SIZEOF['long']
|
||||
else
|
||||
2 * RbConfig::SIZEOF['void*']
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче