]> git.ipfire.org Git - thirdparty/gcc.git/commit
asan: Fix up build_check_stmt gsi handling [PR117209]
authorJakub Jelinek <jakub@redhat.com>
Thu, 24 Oct 2024 10:45:34 +0000 (12:45 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 24 Oct 2024 10:45:34 +0000 (12:45 +0200)
commit885143fa77599c44bfdd4e8e6b6987b7824db6ba
tree1e4879ca3c41c5b5b94aacdb5cd5b83da0483542
parentf6fbc0d2422ce9bea6a23226f4a13a76ffd1784b
asan: Fix up build_check_stmt gsi handling [PR117209]

gsi_safe_insert_before properly updates gsi_bb in gimple_stmt_iterator
in case it splits objects, but unfortunately build_check_stmt was in
some places (but not others) using a copy of the iterator rather than
the iterator passed from callers and so didn't propagate that to callers.
I guess it didn't matter much before when it was just using
gsi_insert_before as that really didn't change the iterator.
The !before_p case is apparently dead code, nothing is calling it with
before_p=false since around 4.9.

2024-10-24  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/117209
* asan.cc (maybe_cast_to_ptrmode): Formatting fix.
(build_check_stmt): Don't copy *iter into gsi, perform all
the updates on iter directly.

* gcc.dg/asan/pr117209.c: New test.
gcc/asan.cc
gcc/testsuite/gcc.dg/asan/pr117209.c [new file with mode: 0644]