]> git.notmuchmail.org Git - notmuch/commitdiff
Handle errors in mime_node_open
authorAustin Clements <amdragon@MIT.EDU>
Tue, 6 Mar 2012 18:26:57 +0000 (18:26 +0000)
committerDavid Bremner <bremner@debian.org>
Sun, 11 Mar 2012 01:25:19 +0000 (21:25 -0400)
mime-node.c

index d6b4506cbad5b7b19271bd237d87860bb4232ce8..a95bdabc43d86bffd8ce55eaffda2f2395825900 100644 (file)
@@ -97,11 +97,26 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
     }
 
     mctx->stream = g_mime_stream_file_new (mctx->file);
     }
 
     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);
     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);
 
     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;
 
     mctx->cryptoctx = cryptoctx;
     mctx->decrypt = decrypt;