unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Justus Winter <4winter@informatik.uni-hamburg.de>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH] Fix error reporting in notmuch_database_find_message_by_filename
Date: Sat, 17 Mar 2012 13:26:32 -0400	[thread overview]
Message-ID: <20120317172632.GM2670@mit.edu> (raw)
In-Reply-To: <1332002487-32411-2-git-send-email-4winter@informatik.uni-hamburg.de>

Quoth Justus Winter on Mar 17 at  5:41 pm:
> Formerly it was possible for *message_ret to be left
> uninitialized. The documentation however clearly states that "[o]n any
> failure or when the message is not found, this function initializes
> '*message' to NULL".
> 
> Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
> ---

Good catch.  Actually, it looks like the error handling path in this
function was completely bogus without this, since it checks if
*message_ret is non-NULL and destroys it if so, even though the
function may not have been the one to set it to NULL (and it may have
been uninitialized in the caller).

So, LGTM.

>  lib/database.cc |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/database.cc b/lib/database.cc
> index 8f8df1a..16c4354 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -1825,6 +1825,9 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
>      if (message_ret == NULL)
>  	return NOTMUCH_STATUS_NULL_POINTER;
>  
> +    /* return NULL on any failure */
> +    *message_ret = NULL;
> +
>      local = talloc_new (notmuch);
>  
>      try {

  reply	other threads:[~2012-03-17 17:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-17 16:41 Fix error reporting in notmuch_database_find_message_by_filename Justus Winter
2012-03-17 16:41 ` [PATCH] " Justus Winter
2012-03-17 17:26   ` Austin Clements [this message]
2012-03-18 11:46   ` David Bremner

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=20120317172632.GM2670@mit.edu \
    --to=amdragon@mit.edu \
    --cc=4winter@informatik.uni-hamburg.de \
    --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).