emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/igc 347df7bc8ff 2/6: In dflt_scanx, check types more carefully


From: Gerd Moellmann
Subject: scratch/igc 347df7bc8ff 2/6: In dflt_scanx, check types more carefully
Date: Thu, 16 May 2024 04:44:58 -0400 (EDT)

branch: scratch/igc
commit 347df7bc8ffa736497a393acaf90712f58603d9a
Author: Helmut Eller <eller.helmut@gmail.com>
Commit: Gerd Möllmann <gerd@gnu.org>

    In dflt_scanx, check types more carefully
    
    * src/igc.c (dflt_scanx): Make sure that obj_type and pvec_type are in
    the valid range before using them as index.
---
 src/igc.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/igc.c b/src/igc.c
index 54f2480865c..b03b1e996d8 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -1242,10 +1242,17 @@ dflt_scanx (mps_ss_t ss, mps_addr_t base_start, 
mps_addr_t base_limit,
        if (closure)
          {
            struct igc_stats *st = closure;
-           st->obj[header->obj_type].nwords += header->nwords;
-           st->obj[header->obj_type].nobjs += 1;
-           st->obj[header->pvec_type].nwords += header->nwords;
-           st->obj[header->pvec_type].nobjs += 1;
+           mps_word_t obj_type = header->obj_type;
+           igc_assert (obj_type < IGC_OBJ_LAST);
+           st->obj[obj_type].nwords += header->nwords;
+           st->obj[obj_type].nobjs += 1;
+           if (obj_type != IGC_OBJ_PAD)
+             {
+               mps_word_t pvec_type = header->pvec_type;
+               igc_assert (pvec_type <= PVEC_TAG_MAX);
+               st->obj[pvec_type].nwords += header->nwords;
+               st->obj[pvec_type].nobjs += 1;
+             }
          }
 
        switch (header->obj_type)
@@ -3100,7 +3107,9 @@ DEFUN ("igc-info", Figc_info, Sigc_info, 0, 0, 0, doc : 
/* */)
   struct igc *gc = global_igc;
   struct igc_stats st = { 0 };
   mps_res_t res;
-  IGC_WITH_PARKED (gc) { res = mps_pool_walk (gc->dflt_pool, dflt_scanx, &st); 
}
+  IGC_WITH_PARKED (gc) {
+     res = mps_pool_walk (gc->dflt_pool, dflt_scanx, &st);
+  }
   if (res != MPS_RES_OK)
     error ("Error %d walking memory", res);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]