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-text.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sprinter-text.c') diff --git a/sprinter-text.c b/sprinter-text.c index dfa54b57..10343be4 100644 --- a/sprinter-text.c +++ b/sprinter-text.c @@ -38,6 +38,8 @@ text_string_len (struct sprinter *sp, const char *val, size_t len) static void text_string (struct sprinter *sp, const char *val) { + if (val == NULL) + val = ""; text_string_len (sp, val, strlen (val)); } -- cgit v1.2.3