]> git.notmuchmail.org Git - notmuch/commitdiff
add_message: Avoid a memory leak when user holds on to message return.
authorCarl Worth <cworth@cworth.org>
Tue, 17 Nov 2009 16:50:14 +0000 (08:50 -0800)
committerCarl Worth <cworth@cworth.org>
Tue, 17 Nov 2009 16:50:14 +0000 (08:50 -0800)
When this function was originally written, the 'message' object was
always destroyed locally, so I thought it would be good to use a NULL
talloc context to make it more obvious if there was any leak.

Since then, however, this function has been changed to optionally
return the added message, and in that case we *don't* free the message
locally, so let's let the database be the talloc context.

lib/database.cc

index 8177c6b68109f1df0a56364d3a9e55c52920d049..583a16edb519e635d960f9dcc3fed58e06dd0ead 100644 (file)
@@ -911,8 +911,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
         * (which may or may not reference an existing document in the
         * database). */
 
         * (which may or may not reference an existing document in the
         * database). */
 
-       /* Use NULL for owner since we want to free this locally. */
-       message = _notmuch_message_create_for_message_id (NULL,
+       message = _notmuch_message_create_for_message_id (database,
                                                          notmuch,
                                                          message_id,
                                                          &private_status);
                                                          notmuch,
                                                          message_id,
                                                          &private_status);