From aa6b5ec5b9344bce0ea38d294aef0782c3745548 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 2 Oct 2022 14:47:14 -0400 Subject: Add assertions for all non-null pointers in the public API --- src/uri.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/uri.c') diff --git a/src/uri.c b/src/uri.c index aed669c8..bc9d9fad 100644 --- a/src/uri.c +++ b/src/uri.c @@ -9,6 +9,7 @@ #include "serd/string_view.h" #include "serd/uri.h" +#include #include #include #include @@ -18,6 +19,8 @@ char* serd_parse_file_uri(const char* const uri, char** const hostname) { + assert(uri); + const char* path = uri; if (hostname) { *hostname = NULL; @@ -71,6 +74,8 @@ serd_parse_file_uri(const char* const uri, char** const hostname) bool serd_uri_string_has_scheme(const char* const string) { + assert(string); + if (is_alpha(string[0])) { for (size_t i = 1; string[i]; ++i) { if (!is_uri_scheme_char(string[i])) { @@ -89,6 +94,8 @@ serd_uri_string_has_scheme(const char* const string) SerdURIView serd_parse_uri(const char* const string) { + assert(string); + SerdURIView result = SERD_URI_NULL; const char* ptr = string; @@ -440,6 +447,9 @@ serd_write_uri(const SerdURIView uri, const SerdWriteFunc sink, void* const stream) { + assert(sink); + assert(stream); + size_t len = 0; if (uri.scheme.data) { -- cgit v1.2.1