aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authorUrabe, Shyouhei <shyouhei@ruby-lang.org>2019-04-24 15:30:25 +0900
committerUrabe, Shyouhei <shyouhei@ruby-lang.org>2019-04-26 15:59:40 +0900
commitf02760fc0a455f376ad1a855fd1a5e9252c8267c (patch)
tree184205c873356ab294ff0819bd1982dce22f9ad1 /variable.c
parent3ba485c0bfcfc0be351ef8278cd27187f4c11906 (diff)
downloadruby-f02760fc0a455f376ad1a855fd1a5e9252c8267c.tar.gz
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
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/variable.c b/variable.c
index 2c69e2169c..cb24076dd0 100644
--- a/variable.c
+++ b/variable.c
@@ -2472,6 +2472,7 @@ rb_autoload_load(VALUE mod, ID id)
}
/* autoload_data_i can be deleted by another thread while require */
+ state.result = Qfalse;
result = rb_ensure(autoload_require, (VALUE)&state,
autoload_reset, (VALUE)&state);