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/syntax.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/syntax.c') diff --git a/src/syntax.c b/src/syntax.c index d75865b1..6b95446d 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -5,6 +5,7 @@ #include "serd/syntax.h" +#include #include #include @@ -25,6 +26,8 @@ static const Syntax syntaxes[] = { SerdSyntax serd_syntax_by_name(const char* const name) { + assert(name); + const size_t len = strlen(name); if (len) { for (const Syntax* s = syntaxes; s->name; ++s) { @@ -33,12 +36,15 @@ serd_syntax_by_name(const char* const name) } } } + return SERD_SYNTAX_EMPTY; } SerdSyntax serd_guess_syntax(const char* const filename) { + assert(filename); + const char* ext = strrchr(filename, '.'); if (ext && ext[1]) { const size_t ext_len = strlen(ext); -- cgit v1.2.1