tmp->data = task->msg->begin;
tmp->len = task->msg->len;
stream = g_mime_stream_mem_new_with_byte_array (tmp);
+ /*
+ * This causes g_mime_stream not to free memory by itself as it is memory allocated by
+ * pool allocator
+ */
+ g_mime_stream_mem_set_owner (stream, FALSE);
+
msg_debug ("process_message: construct mime parser from string length %ld", (long int)task->msg->len);
/* create a new parser object to parse the stream */
parser = g_mime_parser_new_with_stream (stream);
/* parse the message from the stream */
message = g_mime_parser_construct_message (parser);
+
+ if (message == NULL) {
+ msg_warn ("process_message: cannot construct mime from stream");
+ return -1;
+ }
task->message = message;
memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_object_unref, task->message);
tmp->data = session->learn_buf->begin;
tmp->len = session->learn_buf->len;
stream = g_mime_stream_mem_new_with_byte_array (tmp);
+ /*
+ * This causes g_mime_stream not to free memory by itself as it is memory allocated by
+ * pool allocator
+ */
+ g_mime_stream_mem_set_owner (stream, FALSE);
/* create a new parser object to parse the stream */
parser = g_mime_parser_new_with_stream (stream);
int rc;
char *url_str = NULL;
struct uri *new;
+
+ if (!content->data || content->len == 0) {
+ msg_warn ("url_parse_text: got empty text part");
+ return;
+ }
if (url_init () == 0) {
do {
char *url_str = NULL;
struct uri *new;
+ if (!content->data || content->len == 0) {
+ msg_warn ("url_parse_text: got empty text part");
+ return;
+ }
+
if (url_init () == 0) {
do {
rc = g_regex_match_full (html_re, (const char *)content->data, content->len, pos, 0, &info, &err);
task->msg = in;
msg_debug ("read_socket: got string of length %ld", (long int)task->msg->len);
r = process_message (task);
+ if (r == -1) {
+ msg_warn ("read_socket: processing of message failed");
+ task->last_error = "MIME processing error";
+ task->error_code = RSPAMD_FILTER_ERROR;
+ task->state = WRITE_ERROR;
+ write_socket (task);
+ }
r = process_filters (task);
if (r == -1) {
task->last_error = "Filter processing error";