Commit add5a8e9

add5a8e965beMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

fix(codegen): super_with_block guards type lookup against shorter list (#810)

compile_super_with_block_inline indexed flocals_t_sw using the flocals_n_sw length. If the names list was longer than the types list (mismatched serialization edge case), the out-of-range read returned nil and the subsequent c_type(nil) / c_default_val(nil) crashed.

Bound the type read to flocals_t_sw.length; fall back to "int" when out of range. The mismatch is the symptom -- this guard makes the crash a wrong-but-recoverable codegen instead of a hard abort.

Closes #810

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
add5a8e965be
Parent
55acc57bcbec

spinel_codegen.rbmodifiedView file

@@ -13833,12 +13833,20 @@
1383313833 end
1383413834 kf_sw = 0
1383513835 while kf_sw < flocals_n_sw.length
13836+ # Issue #810: bound the type lookup. If the scope name list is
13837+ # longer than the type list (mismatched serialization), fall back
13838+ # to "int" so we don't pass nil through c_type / c_default_val
13839+ # and crash.
13840+ t_sw = "int"
13841+ if kf_sw < flocals_t_sw.length
13842+ t_sw = flocals_t_sw[kf_sw]
13843+ end
1383613844 tname_lv = flocals_n_sw[kf_sw] + suffix_sw
13837- emit(" " + c_type(flocals_t_sw[kf_sw]) + " lv_" + tname_lv + " = " + c_default_val(flocals_t_sw[kf_sw]) + ";")
13845+ emit(" " + c_type(t_sw) + " lv_" + tname_lv + " = " + c_default_val(t_sw) + ";")
1383813846 map_from_sw.push(flocals_n_sw[kf_sw])
1383913847 map_to_sw.push(tname_lv)
13840- declare_var(tname_lv, flocals_t_sw[kf_sw])
13841- declare_var(flocals_n_sw[kf_sw], flocals_t_sw[kf_sw])
13848+ declare_var(tname_lv, t_sw)
13849+ declare_var(flocals_n_sw[kf_sw], t_sw)
1384213850 kf_sw = kf_sw + 1
1384313851 end
1384413852 end