forked from mirrors/treebird
Fix use after free for notifications
FossilOrigin-Name: 62bbe10354d66ecc0d9b5ca594540d549971be22a3d4c761db0f3a6c6ac4ca75
This commit is contained in:
parent
f87d88374e
commit
ef93dcb0fe
5 changed files with 13 additions and 19 deletions
|
@ -122,7 +122,6 @@ static void fetch_account_page(struct session* ssn,
|
|||
struct mstdnt_relationship* relationships = NULL;
|
||||
size_t relationships_len = 0;
|
||||
|
||||
|
||||
int lookup_type = config_experimental_lookup ? MSTDNT_LOOKUP_ACCT : MSTDNT_LOOKUP_ID;
|
||||
|
||||
if (mastodont_get_account(api, lookup_type, id, &acct, &storage))
|
||||
|
@ -358,8 +357,7 @@ void content_account_bookmarks(struct session* ssn, mastodont_t* api, char** dat
|
|||
struct mstdnt_storage storage = { 0 };
|
||||
char* status_format = NULL,
|
||||
*navigation_box = NULL,
|
||||
*output = NULL,
|
||||
*page = NULL;
|
||||
*output = NULL;
|
||||
char* start_id;
|
||||
|
||||
struct mstdnt_bookmarks_args args = {
|
||||
|
@ -391,11 +389,8 @@ void content_account_bookmarks(struct session* ssn, mastodont_t* api, char** dat
|
|||
NULL);
|
||||
}
|
||||
|
||||
easprintf(&page, "%s%s",
|
||||
STR_NULL_EMPTY(status_format),
|
||||
easprintf(&output, data_bookmarks_page_html, status_format,
|
||||
STR_NULL_EMPTY(navigation_box));
|
||||
|
||||
easprintf(&output, data_bookmarks_page_html, page);
|
||||
|
||||
struct base_page b = {
|
||||
.category = BASE_CAT_BOOKMARKS,
|
||||
|
@ -413,7 +408,6 @@ void content_account_bookmarks(struct session* ssn, mastodont_t* api, char** dat
|
|||
if (status_format) free(status_format);
|
||||
if (navigation_box) free(navigation_box);
|
||||
if (output) free(output);
|
||||
if (page) free(page);
|
||||
}
|
||||
|
||||
void content_account_favourites(struct session* ssn, mastodont_t* api, char** data)
|
||||
|
@ -454,12 +448,8 @@ void content_account_favourites(struct session* ssn, mastodont_t* api, char** da
|
|||
statuses[status_count-1].id,
|
||||
NULL);
|
||||
}
|
||||
|
||||
easprintf(&page, "%s%s",
|
||||
STR_NULL_EMPTY(status_format),
|
||||
STR_NULL_EMPTY(navigation_box));
|
||||
|
||||
easprintf(&output, data_favourites_page_html, page);
|
||||
easprintf(&output, data_favourites_page_html, status_format,
|
||||
navigation_box ? navigation_box : "");
|
||||
|
||||
struct base_page b = {
|
||||
.category = BASE_CAT_FAVOURITES,
|
||||
|
@ -477,5 +467,4 @@ void content_account_favourites(struct session* ssn, mastodont_t* api, char** da
|
|||
if (status_format) free(status_format);
|
||||
if (navigation_box) free(navigation_box);
|
||||
if (output) free(output);
|
||||
if (page) free(page);
|
||||
}
|
||||
|
|
|
@ -185,8 +185,8 @@ void content_notifications(struct session* ssn, mastodont_t* api, char** data)
|
|||
.exclude_visibilities = 0,
|
||||
.include_types = 0,
|
||||
.with_muted = 1,
|
||||
.max_id = NULL,
|
||||
.min_id = NULL,
|
||||
.max_id = ssn->post.max_id,
|
||||
.min_id = ssn->post.min_id,
|
||||
.since_id = NULL,
|
||||
.offset = 0,
|
||||
.limit = 20,
|
||||
|
@ -195,12 +195,12 @@ void content_notifications(struct session* ssn, mastodont_t* api, char** data)
|
|||
if (mastodont_get_notifications(api, &args, &storage, ¬ifs, ¬ifs_len) == 0)
|
||||
{
|
||||
notif_html = construct_notifications(api, notifs, notifs_len, NULL);
|
||||
mstdnt_cleanup_notifications(notifs, notifs_len);
|
||||
start_id = ssn->post.start_id ? ssn->post.start_id : notifs[0].id;
|
||||
navigation_box = construct_navigation_box(start_id,
|
||||
notifs[0].id,
|
||||
notifs[notifs_len-1].id,
|
||||
NULL);
|
||||
mstdnt_cleanup_notifications(notifs, notifs_len);
|
||||
}
|
||||
else
|
||||
notif_html = construct_error(storage.error, E_NOTICE, 1, NULL);
|
||||
|
@ -209,7 +209,7 @@ void content_notifications(struct session* ssn, mastodont_t* api, char** data)
|
|||
|
||||
easprintf(&page, data_notifications_page_html,
|
||||
notif_html ? notif_html : "",
|
||||
navigation_box);
|
||||
navigation_box ? navigation_box : "");
|
||||
|
||||
struct base_page b = {
|
||||
.category = BASE_CAT_NOTIFICATIONS,
|
||||
|
|
|
@ -365,6 +365,8 @@ char* construct_status(mastodont_t* api,
|
|||
size_t favourites_len = 0;
|
||||
size_t reblogs_len = 0;
|
||||
|
||||
if (!status) return NULL;
|
||||
|
||||
// If focused, show status interactions
|
||||
if ((flags & STATUS_FOCUSED) == STATUS_FOCUSED &&
|
||||
(status->reblogs_count || status->favourites_count))
|
||||
|
@ -493,6 +495,7 @@ static char* construct_status_voidwrap(void* passed, size_t index, int* res)
|
|||
|
||||
char* construct_statuses(mastodont_t* api, struct mstdnt_status* statuses, size_t size, size_t* ret_size)
|
||||
{
|
||||
if (!(statuses && size)) return NULL;
|
||||
struct status_args args = {
|
||||
.api = api,
|
||||
.status = statuses,
|
||||
|
|
|
@ -4,3 +4,4 @@
|
|||
<div class="bookmarks-container">
|
||||
%s
|
||||
</div>
|
||||
%s
|
||||
|
|
|
@ -4,3 +4,4 @@
|
|||
<div class="favourites-container">
|
||||
%s
|
||||
</div>
|
||||
%s
|
||||
|
|
Loading…
Reference in a new issue