summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-03-15 14:32:52 +0100
committerStefan Metzmacher <metze@samba.org>2010-03-15 15:08:23 +0100
commit10ed809a1a31be50ce09142eb99b3a243ae8b940 (patch)
tree07e113bf962b58cb301f8f5ba62c8ccdff1ff6c9
parent1eb0fbe68d4ca00ec482cbdb9f73bc2af8f953bf (diff)
downloadsamba-10ed809a1a31be50ce09142eb99b3a243ae8b940.tar.gz
samba-10ed809a1a31be50ce09142eb99b3a243ae8b940.tar.bz2
samba-10ed809a1a31be50ce09142eb99b3a243ae8b940.zip
talloc_stack: make sure we never let talloc_tos() return ts->talloc_stack[-1]
In smbd there's a small gab between TALLOC_FREE(frame); before be call smbd_parent_loop() where we don't have a valid talloc stackframe. smbd_parent_loop() calls talloc_stackframe() only within the while(1) loop. As DEBUG(2,("waiting for connections")) uses talloc_tos() to construct the time header for the debug message we crash on some systems. metze
-rw-r--r--lib/util/talloc_stack.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/util/talloc_stack.c b/lib/util/talloc_stack.c
index 596efbf6cd..58d22e378a 100644
--- a/lib/util/talloc_stack.c
+++ b/lib/util/talloc_stack.c
@@ -181,7 +181,7 @@ TALLOC_CTX *talloc_tos(void)
struct talloc_stackframe *ts =
(struct talloc_stackframe *)SMB_THREAD_GET_TLS(global_ts);
- if (ts == NULL) {
+ if (ts == NULL || ts->talloc_stacksize == 0) {
talloc_stackframe();
ts = (struct talloc_stackframe *)SMB_THREAD_GET_TLS(global_ts);
DEBUG(0, ("no talloc stackframe around, leaking memory\n"));