From 7de9f5a9c1d62a944ca74e72013e226ee47b5cb4 Mon Sep 17 00:00:00 2001 From: Steffen Kaiser Date: Wed, 5 Mar 2008 14:10:14 +0100 Subject: Leaked a t_pop() call in I/O handler 0x805b350 Raw backtrace: imap [0x80ad741] -> imap [0x80ad65c] -> imap(io_loop_handler _run+0x1ce) [0x80b35ce] -> imap(io_loop_run+0x28) [0x80b29a8] -> imap(main+0x5a0) [0x8063590] -> /lib/tls/i686/cmov/libc.so.6(__lib c_start_main+0xc8) [0xb7e37ea8] -> imap [0x8055e31] child 18478 (imap) killed with signal 6 Cause is, if sendmail fails with an exit code != 0, the function returns with -1 immediately skipping the t_pop() before the end of the function. This fixes it. --- mailtrain.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mailtrain.c b/mailtrain.c index cb571db..08f0534 100644 --- a/mailtrain.c +++ b/mailtrain.c @@ -125,6 +125,7 @@ static int process_tmpdir(struct mailbox_transaction_context *ctx, int fd; char *buf; enum classification wanted; + int rc = 0; t_push(); @@ -141,13 +142,15 @@ static int process_tmpdir(struct mailbox_transaction_context *ctx, if (run_sendmail(fd, wanted)) { mail_storage_set_error(ctx->box->storage, "failed to send mail"); - return -1; + debug("run program failed with exit code %d\n", rc); + rc = -1; + break; } } t_pop(); - return 0; + return rc; } static void clear_tmpdir(struct antispam_transaction_context *ast) -- cgit v1.2.3