[前][次][番号順一覧][スレッド一覧]

ruby-changes:69387

From: Nobuyoshi <ko1@a...>
Date: Sun, 24 Oct 2021 19:25:16 +0900 (JST)
Subject: [ruby-changes:69387] 7459a32af3 (master): suppress warnings for probable NULL dererefences

https://git.ruby-lang.org/ruby.git/commit/?id=7459a32af3

From 7459a32af3e89ea9990efb4d76bfdc869e480ffe Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 25 Oct 2017 18:32:44 +0900
Subject: suppress warnings for probable NULL dererefences

---
 compile.c  | 1 +
 encoding.c | 5 ++++-
 vm.c       | 1 +
 vm_core.h  | 2 ++
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/compile.c b/compile.c
index 055d4e85f5..62a047be78 100644
--- a/compile.c
+++ b/compile.c
@@ -4774,6 +4774,7 @@ compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const https://github.com/ruby/ruby/blob/trunk/compile.c#L4774
 
         LINK_ELEMENT *insn_element = LAST_ELEMENT(pre);
         iobj = (INSN *)get_prev_insn((INSN *)insn_element); /* send insn */
+	ASSUME(iobj);
         ELEM_REMOVE(LAST_ELEMENT(pre));
         ELEM_REMOVE((LINK_ELEMENT *)iobj);
         pre->last = iobj->link.prev;
diff --git a/encoding.c b/encoding.c
index 2fb1c42047..2737108379 100644
--- a/encoding.c
+++ b/encoding.c
@@ -496,6 +496,7 @@ set_base_encoding(struct enc_table *enc_table, int index, rb_encoding *base) https://github.com/ruby/ruby/blob/trunk/encoding.c#L496
 {
     rb_encoding *enc = enc_table->list[index].enc;
 
+    ASSUME(enc);
     enc_table->list[index].base = base;
     if (ENC_DUMMY_P(base)) ENC_SET_DUMMY((rb_raw_encoding *)enc);
     return enc;
@@ -758,7 +759,9 @@ rb_encdb_alias(const char *alias, const char *orig) https://github.com/ruby/ruby/blob/trunk/encoding.c#L759
 void
 rb_encdb_set_unicode(int index)
 {
-    ((rb_raw_encoding *)rb_enc_from_index(index))->flags |= ONIGENC_FLAG_UNICODE;
+    rb_raw_encoding *enc = (rb_raw_encoding *)rb_enc_from_index(index);
+    ASSUME(enc);
+    enc->flags |= ONIGENC_FLAG_UNICODE;
 }
 
 static void
diff --git a/vm.c b/vm.c
index 2f6a244eee..a18b2140d3 100644
--- a/vm.c
+++ b/vm.c
@@ -1653,6 +1653,7 @@ rb_vm_cref_replace_with_duplicated_cref(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L1653
     const rb_execution_context_t *ec = GET_EC();
     const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
     rb_cref_t *cref = vm_cref_replace_with_duplicated_cref(cfp->ep);
+    ASSUME(cref);
     return cref;
 }
 
diff --git a/vm_core.h b/vm_core.h
index 8519da8f9e..76d0025613 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -1367,6 +1367,7 @@ vm_assert_env(VALUE obj) https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1367
 }
 #endif
 
+RBIMPL_ATTR_NONNULL((1))
 static inline VALUE
 VM_ENV_ENVVAL(const VALUE *ep)
 {
@@ -1376,6 +1377,7 @@ VM_ENV_ENVVAL(const VALUE *ep) https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1377
     return envval;
 }
 
+RBIMPL_ATTR_NONNULL((1))
 static inline const rb_env_t *
 VM_ENV_ENVVAL_PTR(const VALUE *ep)
 {
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]