Skip to content

Commit

Permalink
Fix Possible Control flow issues (DEADCODE)
Browse files Browse the repository at this point in the history
Coverity Scan says `Execution cannot reach this statement: "poison_object(v);"`,
so do nothing when `ptr` is always 0 without address_sanitizer.
  • Loading branch information
znz committed May 29, 2019
1 parent e04d10b commit aee36bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 8 additions & 0 deletions internal.h
Expand Up @@ -155,6 +155,14 @@ asan_poison_object(VALUE obj)
asan_poison_memory_region(ptr, SIZEOF_VALUE);
}

#if !__has_feature(address_sanitizer)
#define asan_poison_object_if(ptr, obj) ((void)(ptr), (void)(obj))
#else
#define asan_poison_object_if(ptr, obj) do { \
if (ptr) asan_poison_object(obj); \
} while (0)
#endif

/*!
* This function predicates if the given object is fully addressable or not.
*
Expand Down
8 changes: 2 additions & 6 deletions iseq.c
Expand Up @@ -1087,9 +1087,7 @@ remove_coverage_i(void *vstart, void *vend, size_t stride, void *data)
ISEQ_COVERAGE_SET(iseq, Qnil);
}

if (ptr) {
asan_poison_object(v);
}
asan_poison_object_if(ptr, v);
}
return 0;
}
Expand Down Expand Up @@ -3239,9 +3237,7 @@ trace_set_i(void *vstart, void *vend, size_t stride, void *data)
rb_iseq_trace_set(rb_iseq_check((rb_iseq_t *)v), turnon_events);
}

if (ptr) {
asan_poison_object(v);
}
asan_poison_object_if(ptr, v);
}
return 0;
}
Expand Down

0 comments on commit aee36bf

Please sign in to comment.