aboutsummaryrefslogtreecommitdiffhomepage
path: root/database.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-10-27 16:19:20 -0700
committerGravatar Carl Worth <cworth@cworth.org>2009-10-27 16:19:20 -0700
commit203a717d64864411eb6802c06a5a0ad1cf98e077 (patch)
tree8dad5abcb17bf07eef0a5e16b99ac4c5ea69145f /database.cc
parent854f82fb91ef9560259e4597d475747e948204d5 (diff)
notmuch_database_add_message: Do not return a message on failure.
The recent, disastrous failure of "notmuch new" would have been avoided with this change. The new_command function was basically assuming that it would only get a message object on success so wasn't destroying the message in the other cases.
Diffstat (limited to 'database.cc')
-rw-r--r--database.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/database.cc b/database.cc
index 8d477eca..0fd0bdad 100644
--- a/database.cc
+++ b/database.cc
@@ -836,6 +836,9 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
const char *from, *to, *subject, *old_filename;
char *message_id;
+ if (message_ret)
+ *message_ret = NULL;
+
message_file = notmuch_message_file_open (filename);
if (message_file == NULL) {
ret = NOTMUCH_STATUS_FILE_ERROR;
@@ -932,7 +935,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
DONE:
if (message) {
- if (message_ret)
+ if (ret == NOTMUCH_STATUS_SUCCESS && message_ret)
*message_ret = message;
else
notmuch_message_destroy (message);