unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch <notmuch@notmuchmail.org>
Subject: [PATCH] json: Avoid calling strlen(NULL)
Date: Tue, 06 Apr 2010 08:25:22 +0100	[thread overview]
Message-ID: <877holavq5.fsf@ut.hh.sledj.net> (raw)

commit b65817262b3a275ecd0ef1898d92ec5508a9f810
Author: David Edmondson <dme@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

             reply	other threads:[~2010-04-06  7:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-06  7:25 David Edmondson [this message]
2010-04-06  8:17 ` [PATCH] json: Avoid calling strlen(NULL) Anthony Towns
2010-04-06  8:31   ` David Edmondson
2010-04-20 15:59   ` Carl Worth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877holavq5.fsf@ut.hh.sledj.net \
    --to=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).