aboutsummaryrefslogtreecommitdiff
path: root/src/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol')
-rw-r--r--src/protocol/pubsub0/sub.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/protocol/pubsub0/sub.c b/src/protocol/pubsub0/sub.c
index cb6d781f..aeccfd25 100644
--- a/src/protocol/pubsub0/sub.c
+++ b/src/protocol/pubsub0/sub.c
@@ -228,9 +228,13 @@ sub0_subscribe(void *arg, const void *buf, size_t sz, nni_opt_type t)
nni_mtx_unlock(&s->lk);
return (NNG_ENOMEM);
}
- if ((newtopic->buf = nni_alloc(sz)) == NULL) {
- nni_mtx_unlock(&s->lk);
- return (NNG_ENOMEM);
+ if (sz > 0) {
+ if ((newtopic->buf = nni_alloc(sz)) == NULL) {
+ nni_mtx_unlock(&s->lk);
+ return (NNG_ENOMEM);
+ }
+ } else {
+ newtopic->buf = NULL;
}
NNI_LIST_NODE_INIT(&newtopic->node);
newtopic->len = sz;