From 6e87cbce27cf617b1416c876cd8293a7910603c0 Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Mon, 5 Jan 2026 19:29:09 +0100 Subject: [PATCH] For functions that write to an output buffer, ignore the buffer pointer if the passed capacity is set to 0 --- url.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/url.c b/url.c index 31f4887..bc578bd 100644 --- a/url.c +++ b/url.c @@ -857,6 +857,8 @@ static void append_fragment(Builder *b, URL_String fragment) int url_serialize(URL url, URL *base, char *dst, int cap) { + ASSERT(cap == 0 || dst != NULL); + if (base != NULL && base->scheme.len == 0) return -1; // Base is not an absolute URL @@ -960,6 +962,8 @@ static URL_b32 is_white_space(char c) int url_remove_white_space(char *src, int len, char *dst, int cap) { + ASSERT(cap == 0 || dst != NULL); + while (len > 0 && is_white_space(src[0])) { src++; len--; @@ -982,6 +986,8 @@ int url_remove_white_space(char *src, int len, char *dst, int cap) int url_percent_decode(URL_String str, char *dst, int cap) { + ASSERT(cap == 0 || dst != NULL); + char *src = str.ptr; int len = str.len; int rd = 0;