Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 14C9A4196F4 for ; Tue, 6 Apr 2010 00:25:28 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8s3XXsbQRGop for ; Tue, 6 Apr 2010 00:25:27 -0700 (PDT) Received: from mail-ew0-f219.google.com (mail-ew0-f219.google.com [209.85.219.219]) by olra.theworths.org (Postfix) with ESMTP id 20D3E4196F0 for ; Tue, 6 Apr 2010 00:25:27 -0700 (PDT) Received: by ewy19 with SMTP id 19so1297787ewy.2 for ; Tue, 06 Apr 2010 00:25:26 -0700 (PDT) Received: by 10.213.37.195 with SMTP id y3mr356427ebd.72.1270538726007; Tue, 06 Apr 2010 00:25:26 -0700 (PDT) Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com [83.217.165.81]) by mx.google.com with ESMTPS id p10sm27096353gvf.22.2010.04.06.00.25.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 06 Apr 2010 00:25:24 -0700 (PDT) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id 62FBE5941EC; Tue, 6 Apr 2010 08:25:22 +0100 (BST) To: notmuch Subject: [PATCH] json: Avoid calling strlen(NULL) From: David Edmondson Date: Tue, 06 Apr 2010 08:25:22 +0100 Message-ID: <877holavq5.fsf@ut.hh.sledj.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2010 07:25:28 -0000 commit b65817262b3a275ecd0ef1898d92ec5508a9f810 Author: David Edmondson 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