aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-create.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:04 +0000
committerNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:12 +0000
commit8f235c90a287ee961153dd94f5ca28b033ebb668 (patch)
treed43c3ab0cf3fae2b62081fa92e1c3f534efdf205 /libctf/ctf-create.c
parent97a2a623d0193dbfc92d92545b63aaffd6099272 (diff)
downloadgdb-8f235c90a287ee961153dd94f5ca28b033ebb668.zip
gdb-8f235c90a287ee961153dd94f5ca28b033ebb668.tar.gz
gdb-8f235c90a287ee961153dd94f5ca28b033ebb668.tar.bz2
libctf: error-handling fixes
libctf/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-create.c (ctf_dtd_insert): Set ENOMEM on the dict if out of memory. (ctf_dvd_insert): Likewise. (ctf_add_function): Report ECTF_RDONLY if this dict is not writable. * ctf-subr.c (ctf_err_warn): Only debug-dump passed-in warnings if the passed-in error code is nonzero: the error on the dict for warnings may relate to a previous error.
Diffstat (limited to 'libctf/ctf-create.c')
-rw-r--r--libctf/ctf-create.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index 5fc50a5..c3223a7 100644
--- a/libctf/ctf-create.c
+++ b/libctf/ctf-create.c
@@ -1257,7 +1257,10 @@ ctf_dtd_insert (ctf_dict_t *fp, ctf_dtdef_t *dtd, int flag, int kind)
const char *name;
if (ctf_dynhash_insert (fp->ctf_dthash, (void *) (uintptr_t) dtd->dtd_type,
dtd) < 0)
- return -1;
+ {
+ ctf_set_errno (fp, ENOMEM);
+ return -1;
+ }
if (flag == CTF_ADD_ROOT && dtd->dtd_data.ctt_name
&& (name = ctf_strraw (fp, dtd->dtd_data.ctt_name)) != NULL)
@@ -1268,6 +1271,7 @@ ctf_dtd_insert (ctf_dict_t *fp, ctf_dtdef_t *dtd, int flag, int kind)
{
ctf_dynhash_remove (fp->ctf_dthash, (void *) (uintptr_t)
dtd->dtd_type);
+ ctf_set_errno (fp, ENOMEM);
return -1;
}
}
@@ -1349,7 +1353,10 @@ int
ctf_dvd_insert (ctf_dict_t *fp, ctf_dvdef_t *dvd)
{
if (ctf_dynhash_insert (fp->ctf_dvhash, dvd->dvd_name, dvd) < 0)
- return -1;
+ {
+ ctf_set_errno (fp, ENOMEM);
+ return -1;
+ }
ctf_list_append (&fp->ctf_dvdefs, dvd);
return 0;
}
@@ -1721,6 +1728,9 @@ ctf_add_function (ctf_dict_t *fp, uint32_t flag,
ctf_dict_t *tmp = fp;
size_t i;
+ if (!(fp->ctf_flags & LCTF_RDWR))
+ return (ctf_set_errno (fp, ECTF_RDONLY));
+
if (ctc == NULL || (ctc->ctc_flags & ~CTF_FUNC_VARARG) != 0
|| (ctc->ctc_argc != 0 && argv == NULL))
return (ctf_set_errno (fp, EINVAL));