X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-evt.c;h=d361c9543f2830b31b72b4975c953553f8bb1332;hb=bc8929bec96e81a7f487d5689f52335b435f0e3e;hp=ed3e4672de0a84ca78ea83af43a58a3d9f247457;hpb=4521c1e7ae5371ab9d639adc617d17fb4e8ded0c;p=src%2Fapp-framework-binder.git diff --git a/src/afb-evt.c b/src/afb-evt.c index ed3e4672..d361c954 100644 --- a/src/afb-evt.c +++ b/src/afb-evt.c @@ -84,7 +84,7 @@ struct afb_evtid { int id; /* fullname of the event */ - char fullname[1]; + char fullname[]; }; /* @@ -316,7 +316,7 @@ struct afb_evtid *afb_evt_evtid_create(const char *fullname) /* allocates the event */ len = strlen(fullname); - evtid = malloc(len + sizeof * evtid); + evtid = malloc(len + 1 + sizeof * evtid); if (evtid == NULL) goto error; @@ -537,7 +537,7 @@ void afb_evt_listener_unref(struct afb_evt_listener *listener) struct afb_evt_listener **prv; struct afb_evtid *evtid; - if (!__atomic_sub_fetch(&listener->refcount, 1, __ATOMIC_RELAXED)) { + if (listener && !__atomic_sub_fetch(&listener->refcount, 1, __ATOMIC_RELAXED)) { /* unlink the listener */ pthread_rwlock_wrlock(&listeners_rwlock);