From 6e7492b36fd83313a219474e5cc7d3caaaa68ce6 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 16 Apr 2009 14:59:01 +0000 Subject: [PATCH] * Minor bugfix to above --- webcit/calendar.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/webcit/calendar.c b/webcit/calendar.c index 2271caf47..1a0384df4 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -1020,6 +1020,7 @@ void load_ical_object(long msgnum, int unread, char msg4_content_type[256] = ""; char msg4_content_encoding[256] = ""; int msg4_content_length = 0; + int msg4_content_alloc = 0; int body_bytes = 0; relevant_partnum[0] = '\0'; @@ -1063,7 +1064,8 @@ void load_ical_object(long msgnum, int unread, ) ) { if (relevant_source != NULL) free(relevant_source); - relevant_source = malloc(msg4_content_length); + msg4_content_alloc = msg4_content_length * 2; + relevant_source = malloc(msg4_content_alloc); relevant_source[0] = 0; body_bytes = 0; } @@ -1081,11 +1083,13 @@ void load_ical_object(long msgnum, int unread, msg4_content_length = atoi(&bptr[16]); } else if (relevant_source != NULL) { - safestrncpy(&relevant_source[body_bytes], bptr, msg4_content_length-body_bytes); - safestrncpy(&relevant_source[body_bytes], "\r\n", msg4_content_length-body_bytes); - body_bytes += (StrLength(Buf) + 2); + safestrncpy(&relevant_source[body_bytes], bptr, msg4_content_alloc-body_bytes); + body_bytes += BufLen; + safestrncpy(&relevant_source[body_bytes], "\r\n", msg4_content_alloc-body_bytes); + body_bytes += 2; } } + if (relevant_source != NULL) lprintf(9, "Here it is:\n%s\n", relevant_source); FreeStrBuf(&Buf); /* If MSG4 didn't give us the part we wanted, but we know that we can find it -- 2.39.2