From: Carl Worth <cworth@cworth.org>
To: Anthony Towns <aj@erisian.com.au>, David Edmondson <dme@dme.org>
Cc: notmuch <notmuch@notmuchmail.org>
Subject: Re: [PATCH] json: Avoid calling strlen(NULL)
Date: Tue, 20 Apr 2010 08:59:52 -0700 [thread overview]
Message-ID: <878w8iw1vr.fsf@yoom.home.cworth.org> (raw)
In-Reply-To: <h2y87b3a4191004060117v5421db8ejbe3030d0626e7440@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 928 bytes --]
> There's already a check in json_quote_chararray for len==0, so it
> might be sensible to say:
>
> return (json_quote_chararray (ctx, str, str != NULL ? strlen (str) : 0));
>
> 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==NULL / len==0
> behaviour fall through into the normal case code?
Yes, that's the correct analysis. Thanks so much.
> commit 5b93a488221b50c02db18d86a550cb3c038c00da
> Author: Anthony <aj@erisian.com.au>
> Date: Tue Apr 6 18:10:39 2010 +1000
>
> json: Avoid calling strlen(NULL), and always return a newly
> talloced array.
I've pushed this out now, (separated into two pieces).
-Carl
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2010-04-20 15:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-06 7:25 [PATCH] json: Avoid calling strlen(NULL) David Edmondson
2010-04-06 8:17 ` Anthony Towns
2010-04-06 8:31 ` David Edmondson
2010-04-20 15:59 ` Carl Worth [this message]
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=878w8iw1vr.fsf@yoom.home.cworth.org \
--to=cworth@cworth.org \
--cc=aj@erisian.com.au \
--cc=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).