idnode: ensure that idnode_insert return value is checked on all places
This commit is contained in:
parent
17319d4927
commit
6cbf1568bb
9 changed files with 57 additions and 11 deletions
|
@ -574,7 +574,12 @@ access_entry_create(const char *uuid, htsmsg_t *conf)
|
|||
|
||||
ae = calloc(1, sizeof(access_entry_t));
|
||||
|
||||
idnode_insert(&ae->ae_id, uuid, &access_entry_class, 0);
|
||||
if (idnode_insert(&ae->ae_id, uuid, &access_entry_class, 0)) {
|
||||
if (uuid)
|
||||
tvherror("access", "invalid uuid '%s'", uuid);
|
||||
free(ae);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TAILQ_INIT(&ae->ae_ipmasks);
|
||||
|
||||
|
|
|
@ -554,7 +554,12 @@ channel_create0
|
|||
{
|
||||
lock_assert(&global_lock);
|
||||
|
||||
idnode_insert(&ch->ch_id, uuid, idc, IDNODE_SHORT_UUID);
|
||||
if (idnode_insert(&ch->ch_id, uuid, idc, IDNODE_SHORT_UUID)) {
|
||||
if (uuid)
|
||||
tvherror("channel", "invalid uuid '%s'", uuid);
|
||||
free(ch);
|
||||
return NULL;
|
||||
}
|
||||
if (RB_INSERT_SORTED(&channels, ch, ch_link, ch_id_cmp)) {
|
||||
tvherror("channel", "id collision!");
|
||||
abort();
|
||||
|
|
|
@ -144,6 +144,8 @@ esfilter_create
|
|||
const idclass_t *c = NULL;
|
||||
uint32_t ct;
|
||||
|
||||
lock_assert(&global_lock);
|
||||
|
||||
esf->esf_caid = -1;
|
||||
esf->esf_caprovider = -1;
|
||||
if (ESF_CLASS_IS_VALID(cls)) {
|
||||
|
@ -159,8 +161,12 @@ esfilter_create
|
|||
tvherror("esfilter", "wrong class %d!", cls);
|
||||
abort();
|
||||
}
|
||||
lock_assert(&global_lock);
|
||||
idnode_insert(&esf->esf_id, uuid, c, 0);
|
||||
if (idnode_insert(&esf->esf_id, uuid, c, 0)) {
|
||||
if (uuid)
|
||||
tvherror("esfilter", "invalid uuid '%s'", uuid);
|
||||
free(esf);
|
||||
return NULL;
|
||||
}
|
||||
if (conf)
|
||||
idnode_load(&esf->esf_id, conf);
|
||||
if (ESF_CLASS_IS_VALID(cls))
|
||||
|
|
|
@ -121,8 +121,10 @@ idnode_insert(idnode_t *in, const char *uuid, const idclass_t *class, int flags)
|
|||
in->in_class = class;
|
||||
do {
|
||||
|
||||
if (uuid_init_bin(&u, uuid))
|
||||
if (uuid_init_bin(&u, uuid)) {
|
||||
in->in_class = NULL;
|
||||
return -1;
|
||||
}
|
||||
memcpy(in->in_uuid, u.bin, sizeof(in->in_uuid));
|
||||
|
||||
c = NULL;
|
||||
|
|
|
@ -1043,7 +1043,12 @@ mpegts_input_create0
|
|||
( mpegts_input_t *mi, const idclass_t *class, const char *uuid,
|
||||
htsmsg_t *c )
|
||||
{
|
||||
idnode_insert(&mi->ti_id, uuid, class, 0);
|
||||
if (idnode_insert(&mi->ti_id, uuid, class, 0)) {
|
||||
if (uuid)
|
||||
tvherror("mpegts", "invalid input uuid '%s'", uuid);
|
||||
free(mi);
|
||||
return NULL;
|
||||
}
|
||||
LIST_INSERT_HEAD(&tvh_inputs, (tvh_input_t*)mi, ti_link);
|
||||
|
||||
/* Defaults */
|
||||
|
|
|
@ -54,8 +54,11 @@ mpegts_mux_instance_create0
|
|||
( mpegts_mux_instance_t *mmi, const idclass_t *class, const char *uuid,
|
||||
mpegts_input_t *mi, mpegts_mux_t *mm )
|
||||
{
|
||||
idnode_insert(&mmi->mmi_id, uuid, class, 0);
|
||||
// TODO: does this need to be an idnode?
|
||||
if (idnode_insert(&mmi->mmi_id, uuid, class, 0)) {
|
||||
free(mmi);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Setup links */
|
||||
mmi->mmi_mux = mm;
|
||||
|
@ -884,7 +887,12 @@ mpegts_mux_create0
|
|||
{
|
||||
char buf[256];
|
||||
|
||||
idnode_insert(&mm->mm_id, uuid, class, 0);
|
||||
if (idnode_insert(&mm->mm_id, uuid, class, 0)) {
|
||||
if (uuid)
|
||||
tvherror("mpegts", "invalid mux uuid '%s'", uuid);
|
||||
free(mm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Enabled by default */
|
||||
mm->mm_enabled = 1;
|
||||
|
|
|
@ -259,7 +259,12 @@ mpegts_mux_sched_create ( const char *uuid, htsmsg_t *conf )
|
|||
}
|
||||
|
||||
/* Insert node */
|
||||
idnode_insert(&mms->mms_id, uuid, &mpegts_mux_sched_class, 0);
|
||||
if (idnode_insert(&mms->mms_id, uuid, &mpegts_mux_sched_class, 0)) {
|
||||
if (uuid)
|
||||
tvherror("muxsched", "invalid uuid '%s'", uuid);
|
||||
free(mms);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Add to list */
|
||||
LIST_INSERT_HEAD(&mpegts_mux_sched_all, mms, mms_link);
|
||||
|
|
|
@ -281,7 +281,12 @@ mpegts_network_create0
|
|||
char buf[256];
|
||||
|
||||
/* Setup idnode */
|
||||
idnode_insert(&mn->mn_id, uuid, idc, 0);
|
||||
if (idnode_insert(&mn->mn_id, uuid, idc, 0)) {
|
||||
if (uuid)
|
||||
tvherror("mpegts", "invalid network uuid '%s'", uuid);
|
||||
free(mn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Default callbacks */
|
||||
mn->mn_display_name = mpegts_network_display_name;
|
||||
|
|
|
@ -831,7 +831,12 @@ service_create0
|
|||
( service_t *t, const idclass_t *class, const char *uuid,
|
||||
int source_type, htsmsg_t *conf )
|
||||
{
|
||||
idnode_insert(&t->s_id, uuid, class, 0);
|
||||
if (idnode_insert(&t->s_id, uuid, class, 0)) {
|
||||
if (uuid)
|
||||
tvherror("service", "invalid uuid '%s'", uuid);
|
||||
free(t);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lock_assert(&global_lock);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue