Skip to content

Commit 8aa2322

Browse files
jhawthornluke-grueightbitraptor
committed
Add slot size assertion to ar_force_convert_table
Co-authored-by: Luke Gruber <luke.gru@gmail.com> Co-authored-by: Matt Valentine-House <matt@eightbitraptor.com>
1 parent 0b5862f commit 8aa2322

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

hash.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ RHASH_AR_TABLE_SIZE_DEC(VALUE h)
604604
static inline void
605605
RHASH_AR_TABLE_CLEAR(VALUE h)
606606
{
607+
RUBY_ASSERT(rb_gc_obj_slot_size(h) >= sizeof(struct RHash) + sizeof(ar_table));
607608
RBASIC(h)->flags &= ~RHASH_AR_TABLE_SIZE_MASK;
608609
RBASIC(h)->flags &= ~RHASH_AR_TABLE_BOUND_MASK;
609610

@@ -719,6 +720,8 @@ ar_force_convert_table(VALUE hash, const char *file, int line)
719720
st_hash_t hashes[RHASH_AR_TABLE_MAX_SIZE];
720721
unsigned int bound, size;
721722

723+
RUBY_ASSERT(rb_gc_obj_slot_size(hash) >= sizeof(struct RHash) + sizeof(ar_table));
724+
722725
// prepare hash values
723726
do {
724727
st_data_t keys[RHASH_AR_TABLE_MAX_SIZE];

0 commit comments

Comments
 (0)