diff options
author | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-07-31 08:53:00 +0000 |
---|---|---|
committer | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-07-31 08:53:00 +0000 |
commit | dadc219c1a246e9e101bfd2d6728e948c05a0ce0 (patch) | |
tree | bbf935d2f3780cbc507657f93feae23ae87fbd39 /gcc/c-family/c-ubsan.c | |
parent | 829b2f3fd8f1c449bc4b01dbef0130bd57f80fc0 (diff) | |
download | gcc-dadc219c1a246e9e101bfd2d6728e948c05a0ce0.tar.gz |
Do UBSAN sanitization just when current_function_decl != NULL_TREE (PR sanitize/81530).
2017-07-31 Martin Liska <mliska@suse.cz>
PR sanitize/81530
* cp-gimplify.c (cp_genericize): Guard condition with flag_sanitize_p
also with current_function_decl non-null equality.
* cp-ubsan.c (cp_ubsan_instrument_vptr_p): Likewise.
* decl.c (compute_array_index_type): Likewise.
* init.c (finish_length_check): Likewise.
* typeck.c (cp_build_binary_op): Likewise.
2017-07-31 Martin Liska <mliska@suse.cz>
PR sanitize/81530
* c-convert.c (convert): Guard condition with flag_sanitize_p
also with current_function_decl non-null equality.
* c-decl.c (grokdeclarator): Likewise.
* c-typeck.c (build_binary_op): Likewise.
2017-07-31 Martin Liska <mliska@suse.cz>
PR sanitize/81530
* convert.c (convert_to_integer_1): Guard condition with flag_sanitize_p
also with current_function_decl non-null equality.
2017-07-31 Martin Liska <mliska@suse.cz>
PR sanitize/81530
* c-ubsan.c (ubsan_maybe_instrument_array_ref):
Guard condition with flag_sanitize_p also with current_function_decl
non-null equality.
(ubsan_maybe_instrument_reference_or_call): Likewise.
2017-07-31 Martin Liska <mliska@suse.cz>
PR sanitize/81530
* g++.dg/ubsan/pr81530.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250730 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family/c-ubsan.c')
-rw-r--r-- | gcc/c-family/c-ubsan.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/c-family/c-ubsan.c b/gcc/c-family/c-ubsan.c index a072d19eda6..541b53009c2 100644 --- a/gcc/c-family/c-ubsan.c +++ b/gcc/c-family/c-ubsan.c @@ -373,7 +373,8 @@ void ubsan_maybe_instrument_array_ref (tree *expr_p, bool ignore_off_by_one) { if (!ubsan_array_ref_instrumented_p (*expr_p) - && sanitize_flags_p (SANITIZE_BOUNDS | SANITIZE_BOUNDS_STRICT)) + && sanitize_flags_p (SANITIZE_BOUNDS | SANITIZE_BOUNDS_STRICT) + && current_function_decl != NULL_TREE) { tree op0 = TREE_OPERAND (*expr_p, 0); tree op1 = TREE_OPERAND (*expr_p, 1); @@ -393,7 +394,8 @@ static tree ubsan_maybe_instrument_reference_or_call (location_t loc, tree op, tree ptype, enum ubsan_null_ckind ckind) { - if (!sanitize_flags_p (SANITIZE_ALIGNMENT | SANITIZE_NULL)) + if (!sanitize_flags_p (SANITIZE_ALIGNMENT | SANITIZE_NULL) + || current_function_decl == NULL_TREE) return NULL_TREE; tree type = TREE_TYPE (ptype); |