summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pamment <apamment@yandex.com>2018-12-02 20:55:32 +1000
committerAndrew Pamment <apamment@yandex.com>2018-12-02 20:55:32 +1000
commitefc181ac1bd639a77644f22f6f046bd4041c6776 (patch)
tree6127033bcc584d4a0545ca7434b681d7566b531e
parent66146781a997c38f0e5739cd856527ac85ce88d6 (diff)
fix for blog crash
-rw-r--r--src/mail_menu.c7
-rw-r--r--src/www_blog.c24
2 files changed, 16 insertions, 15 deletions
diff --git a/src/mail_menu.c b/src/mail_menu.c
index 4e990ae..bd1572c 100644
--- a/src/mail_menu.c
+++ b/src/mail_menu.c
@@ -2061,12 +2061,11 @@ int read_new_msgs(struct user_record *user, struct msg_headers *msghs) {
free(jb);
if (all_unread == 0) {
k = jlr.HighReadMsg;
- for (i = 0; i < msghs->msg_count; i++) {
+ for (i = msghs->msg_count-1; i>=0; i--) {
if (msghs->msgs[i]->msg_h->MsgNum == k) {
- i += 2;
+ i+=2;
break;
- }
- if (msghs->msgs[i]->msg_h->MsgNum > k) {
+ } else if (msghs->msgs[i]->msg_h->MsgNum < k) {
i++;
break;
}
diff --git a/src/www_blog.c b/src/www_blog.c
index 7137f14..c2c55a9 100644
--- a/src/www_blog.c
+++ b/src/www_blog.c
@@ -99,21 +99,23 @@ char *www_blog() {
stralloc_append1(&blog_body, ' ');
continue;
} else if (p[1] != '\0') {
- child_child_tag = www_tag_new(NULL, blog_body.s);
- free(blog_body.s);
- www_tag_add_child(child_tag, child_child_tag);
- blog_body = EMPTY_STRALLOC;
- child_tag = www_tag_new("p", NULL);
- www_tag_add_child(cur_tag, child_tag);
+ if (blog_body.s != NULL) {
+ child_child_tag = www_tag_new(NULL, blog_body.s);
+ free(blog_body.s);
+ www_tag_add_child(child_tag, child_child_tag);
+ blog_body = EMPTY_STRALLOC;
+ child_tag = www_tag_new("p", NULL);
+ www_tag_add_child(cur_tag, child_tag);
+ }
++p;
}
}
- child_child_tag = www_tag_new(NULL, blog_body.s);
-
- free(blog_body.s);
-
- www_tag_add_child(child_tag, child_child_tag);
+ if (blog_body.s != NULL) {
+ child_child_tag = www_tag_new(NULL, blog_body.s);
+ free(blog_body.s);
+ www_tag_add_child(child_tag, child_child_tag);
+ }
}
ptr_vector_apply(&entries, free);
destroy_ptr_vector(&entries);