json: Avoid calling strlen(NULL)
authorDavid Edmondson <dme@dme.org>
Tue, 6 Apr 2010 07:24:00 +0000 (08:24 +0100)
committerCarl Worth <cworth@cworth.org>
Tue, 20 Apr 2010 15:54:51 +0000 (08:54 -0700)
MIME parts may have no filename, which previously resulted in calling
strlen(NULL).

json.c

diff --git a/json.c b/json.c
index 1d0c169449657c49970390ebf76cf98ce11be2e8..3fd923ca787cf62ba3ea4788d976212beb981dba 100644 (file)
--- a/json.c
+++ b/json.c
@@ -105,5 +105,8 @@ json_quote_chararray(const void *ctx, const char *str, const size_t len)
 char *
 json_quote_str(const void *ctx, const char *str)
 {
+    if (str == NULL)
+       str = "";
+
     return (json_quote_chararray (ctx, str, strlen (str)));
 }