unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Fix error reporting in notmuch_database_find_message_by_filename
@ 2012-03-17 16:41 Justus Winter
  2012-03-17 16:41 ` [PATCH] " Justus Winter
  0 siblings, 1 reply; 4+ messages in thread
From: Justus Winter @ 2012-03-17 16:41 UTC (permalink / raw)
  To: notmuch

while valgrinding a crashing python process I noticed that the error
handling in notmuch_database_find_message_by_filename does not work as
advertised in the documentation.

I'd love to see this in the 0.12 release ;)

Justus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Fix error reporting in notmuch_database_find_message_by_filename
  2012-03-17 16:41 Fix error reporting in notmuch_database_find_message_by_filename Justus Winter
@ 2012-03-17 16:41 ` Justus Winter
  2012-03-17 17:26   ` Austin Clements
  2012-03-18 11:46   ` David Bremner
  0 siblings, 2 replies; 4+ messages in thread
From: Justus Winter @ 2012-03-17 16:41 UTC (permalink / raw)
  To: notmuch

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>
---
 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 {
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix error reporting in notmuch_database_find_message_by_filename
  2012-03-17 16:41 ` [PATCH] " Justus Winter
@ 2012-03-17 17:26   ` Austin Clements
  2012-03-18 11:46   ` David Bremner
  1 sibling, 0 replies; 4+ messages in thread
From: Austin Clements @ 2012-03-17 17:26 UTC (permalink / raw)
  To: Justus Winter; +Cc: notmuch

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 {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix error reporting in notmuch_database_find_message_by_filename
  2012-03-17 16:41 ` [PATCH] " Justus Winter
  2012-03-17 17:26   ` Austin Clements
@ 2012-03-18 11:46   ` David Bremner
  1 sibling, 0 replies; 4+ messages in thread
From: David Bremner @ 2012-03-18 11:46 UTC (permalink / raw)
  To: Justus Winter, notmuch

On Sat, 17 Mar 2012 17:41:27 +0100, Justus Winter <4winter@informatik.uni-hamburg.de> wrote:
> 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".
> 

Pushed to 0.12

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-03-18 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2012-03-18 11:46   ` David Bremner

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).