From 94c3b40d41f1ad98719d411ef28b69075fda0579 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Wed, 8 Aug 2012 22:23:33 +0100 Subject: sprinters: bugfix when NULL passed for a string. The string function in a sprinter may be called with a NULL string pointer (eg if a header is absent). This causes a segfault. We fix this by checking for a null pointer in the string functions and update the sprinter documentation. At the moment some output when format=text is done directly rather than via an sprinter: in that case a null pointer is passed to printf or similar and a "(null)" appears in the output. That behaviour is not changed in this patch. --- sprinter.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sprinter.h') diff --git a/sprinter.h b/sprinter.h index 5f431757..912a5262 100644 --- a/sprinter.h +++ b/sprinter.h @@ -27,7 +27,9 @@ typedef struct sprinter { * a list or map, followed or preceded by separators). For string * and string_len, the char * must be UTF-8 encoded. string_len * allows non-terminated strings and strings with embedded NULs - * (though the handling of the latter is format-dependent). + * (though the handling of the latter is format-dependent). For + * string (but not string_len) the string pointer passed may be + * NULL. */ void (*string) (struct sprinter *, const char *); void (*string_len) (struct sprinter *, const char *, size_t); -- cgit v1.2.3