Skip to content

Commit f02760f

Browse files
committedApr 26, 2019
avoid reading uninitialized variable
autoload_reset() can read this state.result. Because autoload_reset is a function passed to rb_ensure, there is a chance when an execption raises before actually filling this memory region. test/ruby/test_defined.rb:test_autoload_noload is one of such case. Found using memory sanitizer. ==54014==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x557a683f3e5a in autoload_reset variable.c:2372:9 #1 0x557a6707a93b in rb_ensure eval.c:1084:5 #2 0x557a683efbf5 in rb_autoload_load variable.c:2475:14 #3 0x557a685fc460 in vm_get_ev_const vm_insnhelper.c:938:4 #4 0x557a68448e0a in vm_exec_core insns.def:267:11
1 parent 3ba485c commit f02760f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed
 

‎variable.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,7 @@ rb_autoload_load(VALUE mod, ID id)
24722472
}
24732473

24742474
/* autoload_data_i can be deleted by another thread while require */
2475+
state.result = Qfalse;
24752476
result = rb_ensure(autoload_require, (VALUE)&state,
24762477
autoload_reset, (VALUE)&state);
24772478

0 commit comments

Comments
 (0)
Please sign in to comment.