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 A0C284196F2 for ; Tue, 20 Apr 2010 08:59:52 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.89 X-Spam-Level: X-Spam-Status: No, score=-2.89 tagged_above=-999 required=5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, T_MIME_NO_TEXT=0.01] 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 TZIevhlelrAr; Tue, 20 Apr 2010 08:59:51 -0700 (PDT) Received: from yoom.home.cworth.org (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 4ED35431FC1; Tue, 20 Apr 2010 08:59:51 -0700 (PDT) Received: by yoom.home.cworth.org (Postfix, from userid 1000) id 6CA6525400A; Tue, 20 Apr 2010 08:59:52 -0700 (PDT) From: Carl Worth To: Anthony Towns , David Edmondson Subject: Re: [PATCH] json: Avoid calling strlen(NULL) In-Reply-To: References: <877holavq5.fsf@ut.hh.sledj.net> Date: Tue, 20 Apr 2010 08:59:52 -0700 Message-ID: <878w8iw1vr.fsf@yoom.home.cworth.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Cc: notmuch 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, 20 Apr 2010 15:59:52 -0000 --=-=-= Content-Transfer-Encoding: quoted-printable > There's already a check in json_quote_chararray for len=3D=3D0, so it > might be sensible to say: >=20 > return (json_quote_chararray (ctx, str, str !=3D NULL ? strlen (str) = : 0)); >=20 > OTOH, the code in json_quote_array to deal with that does the same > thing (returns a literal string containing two quote marks), which > seems wrong -- the normal code path is to talloc to get a newly > allocated, editable string, that might be talloc_free'd later, > wouldn't it make more sense just to let the str=3D=3DNULL / len=3D=3D0 > behaviour fall through into the normal case code? Yes, that's the correct analysis. Thanks so much. > commit 5b93a488221b50c02db18d86a550cb3c038c00da > Author: Anthony > Date: Tue Apr 6 18:10:39 2010 +1000 >=20 > json: Avoid calling strlen(NULL), and always return a newly > talloced array. I've pushed this out now, (separated into two pieces). =2DCarl --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iD8DBQFLzc946JDdNq8qSWgRAsP1AJ9fgpBe6+hZRrq8FRJV3l50kzpv8QCfcal/ i0IWzEcB2C/hBqtiZ3VIu2Q= =N51E -----END PGP SIGNATURE----- --=-=-=--