Skip to content

Commit 6a5a261

Browse files
committed
variable.c: Fix -Wmaybe-uninitialized warnings in rb_gvar_set/rb_gvar_get
Initialize `entry` and `var` to NULL. They are assigned inside RB_VM_LOCKING() but used after it, and the compiler cannot prove the locked block always executes.
1 parent d926f40 commit 6a5a261

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

variable.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ VALUE
10081008
rb_gvar_set(ID id, VALUE val)
10091009
{
10101010
VALUE retval;
1011-
struct rb_global_entry *entry;
1011+
struct rb_global_entry *entry = NULL;
10121012
const rb_box_t *box = rb_current_box();
10131013
bool use_box_tbl = false;
10141014

@@ -1041,8 +1041,8 @@ rb_gvar_get(ID id)
10411041
VALUE retval, gvars, key;
10421042
const rb_box_t *box = rb_current_box();
10431043
bool use_box_tbl = false;
1044-
struct rb_global_entry *entry;
1045-
struct rb_global_variable *var;
1044+
struct rb_global_entry *entry = NULL;
1045+
struct rb_global_variable *var = NULL;
10461046
// TODO: use lock-free rb_id_table when it's available for use (doesn't yet exist)
10471047
RB_VM_LOCKING() {
10481048
entry = rb_global_entry(id);

0 commit comments

Comments
 (0)