]> Git Repo - binutils.git/blobdiff - libctf/ctf-lookup.c
Automatic date update in version.in
[binutils.git] / libctf / ctf-lookup.c
index 9d1e6d8a4a2b23c9d0ad7eade665123f1e7a0f7f..26b3f8863c0136a8bcd963a39cb503a4ffa980b3 100644 (file)
@@ -1,5 +1,5 @@
 /* Symbol, variable and name lookup.
-   Copyright (C) 2019-2021 Free Software Foundation, Inc.
+   Copyright (C) 2019-2022 Free Software Foundation, Inc.
 
    This file is part of libctf.
 
@@ -111,10 +111,14 @@ isqualifier (const char *s, size_t len)
   };
 
   int h = s[len - 1] + (int) len - 105;
-  const struct qual *qp = &qhash[h];
+  const struct qual *qp;
 
-  return (h >= 0 && (size_t) h < sizeof (qhash) / sizeof (qhash[0])
-         && (size_t) len == qp->q_len &&
+  if (h < 0 || (size_t) h >= sizeof (qhash) / sizeof (qhash[0]))
+    return 0;
+
+  qp = &qhash[h];
+
+  return ((size_t) len == qp->q_len &&
          strncmp (qp->q_name, s, qp->q_len) == 0);
 }
 
@@ -172,7 +176,7 @@ ctf_lookup_by_name_internal (ctf_dict_t *fp, ctf_dict_t *child,
          int in_child = 0;
 
          ntype = CTF_ERR;
-         if (child && idx <= child->ctf_pptrtab_len)
+         if (child && idx < child->ctf_pptrtab_len)
            {
              ntype = child->ctf_pptrtab[idx];
              if (ntype)
@@ -202,7 +206,7 @@ ctf_lookup_by_name_internal (ctf_dict_t *fp, ctf_dict_t *child,
              idx = LCTF_TYPE_TO_INDEX (fp, ntype);
 
              ntype = CTF_ERR;
-             if (child && idx <= child->ctf_pptrtab_len)
+             if (child && idx < child->ctf_pptrtab_len)
                {
                  ntype = child->ctf_pptrtab[idx];
                  if (ntype)
This page took 0.024919 seconds and 4 git commands to generate.