From 94286866e7f748254b0f3ec70e4a52b729bc4dd0 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 9 Apr 2003 21:02:34 +0000 Subject: Save the content size in a temp variable until after we've successfully 2003-04-09 Jeffrey Stedfast * providers/imap/camel-imap-utils.c (imap_body_decode): Save the content size in a temp variable until after we've successfully parsed all of the body_type_1part expr. Also fixed a type-o in the body_type_mpart case that caused the parser to fail. (imap_parse_body): On failure to parse the body, as we iterate through the child nodes, set their children/parent/next nodes to NULL so that content_info_free() won't double-free any of the other nodes we have already free'd (or are about to free). svn path=/trunk/; revision=20795 --- camel/providers/imap/camel-imap-utils.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'camel/providers/imap') diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c index 6ca3b5d84a..59977e2e69 100644 --- a/camel/providers/imap/camel-imap-utils.c +++ b/camel/providers/imap/camel-imap-utils.c @@ -776,6 +776,7 @@ imap_body_decode (const char **in, CamelMessageContentInfo *ci, CamelFolder *fol char *description = NULL; char *encoding = NULL; unsigned int len; + size_t size; char *p; if (*inptr++ != '(') @@ -900,7 +901,7 @@ imap_body_decode (const char **in, CamelMessageContentInfo *ci, CamelFolder *fol goto exception; /* size */ - ci->size = strtoul ((const char *) inptr, &p, 10); + size = strtoul ((const char *) inptr, &p, 10); inptr = (const unsigned char *) p; if (header_content_type_is (ctype, "message", "rfc822")) { @@ -943,6 +944,7 @@ imap_body_decode (const char **in, CamelMessageContentInfo *ci, CamelFolder *fol ci->id = id; ci->description = description; ci->encoding = encoding; + ci->size = size; ci->childs = child; } @@ -990,6 +992,13 @@ imap_parse_body (const char **body_p, CamelFolder *folder, if (!(imap_body_decode (&inptr, ci, folder, children))) { for (i = 0; i < children->len; i++) { child = children->pdata[i]; + + /* content_info_free will free all the child + * nodes, but we don't want that. */ + child->next = NULL; + child->parent = NULL; + child->childs = NULL; + camel_folder_summary_content_info_free (folder->summary, child); } *body_p = NULL; -- cgit