diff --git a/sys/include/net/gcoap.h b/sys/include/net/gcoap.h index 6db480d96a1f693acc4930b9e7f243a466cd1607..b3054b8c78b52c22cb6a7544b4fa6fadd72801cd 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 217c1bdcdb37666ce563939a4b3267627c3304b6..630df36848eef36218163965e43654358d9b8279 100644 --- a/sys/net/application_layer/gcoap/gcoap.c +++ b/sys/net/application_layer/gcoap/gcoap.c @@ -22,6 +22,7 @@ #include <stdint.h> #include <stdatomic.h> +#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;