From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 2E792431FBC for ; Tue, 6 Mar 2012 10:27:05 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UCfN5K-MPSUX for ; Tue, 6 Mar 2012 10:27:04 -0800 (PST) Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU [18.9.25.15]) by olra.theworths.org (Postfix) with ESMTP id 999A2431FAE for ; Tue, 6 Mar 2012 10:27:04 -0800 (PST) X-AuditID: 1209190f-b7f8a6d000000914-d7-4f5656f78c6e Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id 59.A7.02324.7F6565F4; Tue, 6 Mar 2012 13:27:04 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q26IR3TN017019; Tue, 6 Mar 2012 13:27:03 -0500 Received: from drake.mit.edu (firewall.royalsociety.org [193.63.75.2]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q26IR0gk010146 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 6 Mar 2012 13:27:02 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1S4z6C-0003am-4q; Tue, 06 Mar 2012 18:27:00 +0000 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH] Handle errors in mime_node_open Date: Tue, 6 Mar 2012 18:26:57 +0000 Message-Id: <1331058417-13776-1-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <87d38w2e7h.fsf@zancas.localnet> References: <87d38w2e7h.fsf@zancas.localnet> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsUixG6nrvsjLMzfYN5hRovrN2cyOzB6PFt1 izmAMYrLJiU1J7MstUjfLoErY9OC3WwFOzgqOnf3Mjcw3mTrYuTkkBAwkXi77zojhC0mceHe eqA4F4eQwD5GidUzVrJAOOsZJW483c0I4Rxkkjg87TUzhDOfUWLrn3tg/WwCGhLb9i8Hs0UE pCV23p3N2sXIwcEsoCbxp0sFJCwsYCBxa90DFhCbRUBV4u7yXewgNq+Ag8T3v/uZIM5QkDi3 +hxYnFNAV+Lo5MnMILaQgI5E55dXrBMY+RcwMqxilE3JrdLNTczMKU5N1i1OTszLSy3SNdHL zSzRS00p3cQIChtOSf4djN8OKh1iFOBgVOLhrdIN8xdiTSwrrsw9xCjJwaQkyjsvGCjEl5Sf UpmRWJwRX1Sak1p8iFGCg1lJhPfb+1B/Id6UxMqq1KJ8mJQ0B4uSOK+a1js/IYH0xJLU7NTU gtQimKwMB4eSBK8NMD6EBItS01Mr0jJzShDSTBycIMN5gIa7gtTwFhck5hZnpkPkTzEqSonz eoIkBEASGaV5cL2wuH7FKA70ijBvAEgVDzAlwHW/AhrMBDS4TTkYZHBJIkJKqoFxUU7kvf4V TqL1X9QLY36HL1NmsmPtM2NIsL8Rv+kMT+L/cCfzVabv/5VGrK5mVtyycrv+lPavHV7+a3rv 1LBd/HBZ3G+yduBjI/5jMy+VvC49dv6eTXeJcIbrGSYL49o7H6eZldw1zWW3/vMxa+5SZ+Pm voWqFdVTbjKxmC4X13Ezna0rtEyJpTgj0VCLuag4EQAny6hCxgIAAA== X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2012 18:27:05 -0000 --- mime-node.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/mime-node.c b/mime-node.c index d6b4506..a95bdab 100644 --- a/mime-node.c +++ b/mime-node.c @@ -97,11 +97,26 @@ mime_node_open (const void *ctx, notmuch_message_t *message, } mctx->stream = g_mime_stream_file_new (mctx->file); + if (!mctx->stream) { + fprintf (stderr, "Out of memory.\n"); + status = NOTMUCH_STATUS_OUT_OF_MEMORY; + goto DONE; + } g_mime_stream_file_set_owner (GMIME_STREAM_FILE (mctx->stream), FALSE); mctx->parser = g_mime_parser_new_with_stream (mctx->stream); + if (!mctx->parser) { + fprintf (stderr, "Out of memory.\n"); + status = NOTMUCH_STATUS_OUT_OF_MEMORY; + goto DONE; + } mctx->mime_message = g_mime_parser_construct_message (mctx->parser); + if (!mctx->mime_message) { + fprintf (stderr, "Failed to parse %s\n", filename); + status = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; + } mctx->cryptoctx = cryptoctx; mctx->decrypt = decrypt; -- 1.7.7.3