diff --git a/sys/include/net/gcoap.h b/sys/include/net/gcoap.h index 6db480d96a..b3054b8c78 100644 --- a/sys/include/net/gcoap.h +++ b/sys/include/net/gcoap.h @@ -506,6 +506,9 @@ void gcoap_register_listener(gcoap_listener_t *listener); * @param[in] code Request code: GCOAP_[GET|POST|PUT|DELETE] * @param[in] path Resource path, *must* start with '/' * + * @pre @p path not `NULL` + * @pre @p path must start with `/` + * * @return 0 on success * @return < 0 on error */ diff --git a/sys/net/application_layer/gcoap/gcoap.c b/sys/net/application_layer/gcoap/gcoap.c index 217c1bdcdb..630df36848 100644 --- a/sys/net/application_layer/gcoap/gcoap.c +++ b/sys/net/application_layer/gcoap/gcoap.c @@ -22,6 +22,7 @@ #include #include +#include "assert.h" #include "net/gcoap.h" #include "mutex.h" #include "random.h" @@ -718,6 +719,8 @@ void gcoap_register_listener(gcoap_listener_t *listener) int gcoap_req_init(coap_pkt_t *pdu, uint8_t *buf, size_t len, unsigned code, const char *path) { + assert((path != NULL) && (path[0] == '/')); + (void)len; pdu->hdr = (coap_hdr_t *)buf;