/* 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.
};
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);
}
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)
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)
*name = ctf_strptr (fp, idx[i->ctn_n]);
sym = tab[i->ctn_n++];
- } while (sym == -1u || sym == 0);
+ }
+ while (sym == -1u || sym == 0);
}
else
{