[PATCH] json: Avoid calling strlen(NULL)
    David Edmondson 
    dme at dme.org
       
    Tue Apr  6 00:25:22 PDT 2010
    
    
  
commit b65817262b3a275ecd0ef1898d92ec5508a9f810
Author: David Edmondson <dme at dme.org>
Date:   Tue Apr 6 08:24:00 2010 +0100
    json: Avoid calling strlen(NULL)
    
    MIME parts may have no filename, which previously resulted in calling
    strlen(NULL).
	Modified json.c
diff --git a/json.c b/json.c
index f90b0fa..b73f22a 100644
--- 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)
+	return (char *)"\"\"";
+
     return (json_quote_chararray (ctx, str, strlen (str)));
 }
dme.
-- 
David Edmondson, http://dme.org
    
    
More information about the notmuch
mailing list