re PR gcov-profile/55417 (AddressSanitizer reports stack-buffer-overflow in profiling...
authorTeresa Johnson <tejohnson@google.com>
Wed, 21 Nov 2012 15:04:45 +0000 (16:04 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 21 Nov 2012 15:04:45 +0000 (16:04 +0100)
PR gcov-profile/55417
* profile.c (compute_working_sets): Check index first
to avoid out-of-bounds array access.

From-SVN: r193697

gcc/ChangeLog
gcc/profile.c

index 7191a156bd961c1e63e288e12127b536daa93c12..5e436013000e88cd7b076a7ac8d7bd90d36b9a55 100644 (file)
@@ -1,3 +1,9 @@
+2012-11-21  Teresa Johnson  <tejohnson@google.com>
+
+       PR gcov-profile/55417
+       * profile.c (compute_working_sets): Check index first
+       to avoid out-of-bounds array access.
+
 2012-11-21  Matthias Klose  <doko@ubuntu.com>
 
        * config/aarch64/t-aarch64-linux: Define MULTIARCH_DIRNAME for
        * 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 <i[34567]86-*-linux* | x86_64-*-linux*> (tmake_file):
        Include i386/t-linux.
index 194ef91f24f028e088f5b88572e73c56800daf18..bbe02b1f00aef758d319edee70c54cdff3e5c794 100644 (file)
@@ -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