unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] lib: Don't delete uninitialized pointers
@ 2012-01-29  5:50 Austin Clements
  2012-01-29  5:50 ` [PATCH 2/3] lib: Release resources if notmuch_database_open fails Austin Clements
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Austin Clements @ 2012-01-29  5:50 UTC (permalink / raw)
  To: notmuch

In the error-handling paths of notmuch_database_open, we call
notmuch_database_close, which "delete"s several objects referenced by
the notmuch_database_t object.  However, some of these pointers may be
uninitialized, resulting in undefined behavior.  Hence, allocate the
notmuch_database_t with talloc_zero to make sure these pointers are
NULL so that "delete"ing them is harmless.
---
 lib/database.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 8103bd9..a6d15a1 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -617,7 +617,7 @@ notmuch_database_open (const char *path,
 	initialized = 1;
     }
 
-    notmuch = talloc (NULL, notmuch_database_t);
+    notmuch = talloc_zero (NULL, notmuch_database_t);
     notmuch->exception_reported = FALSE;
     notmuch->path = talloc_strdup (notmuch, path);
 
-- 
1.7.7.3

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

end of thread, other threads:[~2012-02-04 12:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-29  5:50 [PATCH 1/3] lib: Don't delete uninitialized pointers Austin Clements
2012-01-29  5:50 ` [PATCH 2/3] lib: Release resources if notmuch_database_open fails Austin Clements
2012-01-29  5:50 ` [PATCH 3/3] lib: Use talloc to simplify cleanup in notmuch_database_open Austin Clements
2012-01-30  7:49   ` Tomi Ollila
2012-02-04 12:38   ` David Bremner
2012-01-31  3:43 ` [PATCH 1/3] lib: Don't delete uninitialized pointers Dmitry Kurochkin

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