From patchwork Wed Nov 21 15:06:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [committed] Fix profile.c asan failure (PR gcov-profile/55417) From: Jakub Jelinek X-Patchwork-Id: 200792 Message-Id: <20121121150635.GC2315@tucnak.redhat.com> To: gcc-patches@gcc.gnu.org Date: Wed, 21 Nov 2012 16:06:36 +0100 Hi! I've committed as obvious a patch from Teresa from the PR. Jakub --- gcc/ChangeLog (revision 193696) +++ gcc/ChangeLog (working copy) @@ -1,3 +1,9 @@ +2012-11-21 Teresa Johnson + + PR gcov-profile/55417 + * profile.c (compute_working_sets): Check index first + to avoid out-of-bounds array access. + 2012-11-21 Matthias Klose * config/aarch64/t-aarch64-linux: Define MULTIARCH_DIRNAME for @@ -1400,7 +1406,7 @@ * cppdefault.h (default_include): Document multiarch in multilib member. * cppdefault.c: [LOCAL_INCLUDE_DIR, STANDARD_INCLUDE_DIR] Add an - include directory for multiarch directories. + include directory for multiarch directories. * common.opt: New options --print-multiarch and -imultilib. * config.gcc (tmake_file): Include i386/t-linux. --- gcc/profile.c (revision 193696) +++ gcc/profile.c (working copy) @@ -288,11 +288,11 @@ compute_working_sets (void) else tmp_cum = cum + histo_bucket->cum_value; - /* Next walk through successive working set entries and fill in - the statistics for any whose size we have reached by accumulating - this histogram counter. */ - while (tmp_cum >= working_set_cum_values[ws_ix] - && ws_ix < NUM_GCOV_WORKING_SETS) + /* Next walk through successive working set entries and fill in + the statistics for any whose size we have reached by accumulating + this histogram counter. */ + while (ws_ix < NUM_GCOV_WORKING_SETS + && tmp_cum >= working_set_cum_values[ws_ix]) { gcov_working_sets[ws_ix].num_counters = count; gcov_working_sets[ws_ix].min_counter