forked from mirrors/treebird
Fix various memleaks + overruns
FossilOrigin-Name: 6c24b524226c4bb45eb53effd2b4232cabe7a5588f2e8551e4d159144f015734
This commit is contained in:
parent
56af83d157
commit
dbc737226c
5 changed files with 19 additions and 9 deletions
|
@ -757,6 +757,7 @@ void content_account_blocked(struct session* ssn, mastodont_t* api, char** data)
|
|||
mastodont_get_blocks(api, &m_args, &args, &storage, &accts, &accts_len);
|
||||
|
||||
accounts_page(api, ssn, &storage, "Blocked users", accts, accts_len);
|
||||
mstdnt_cleanup_accounts(accts, accts_len);
|
||||
}
|
||||
|
||||
void content_account_muted(struct session* ssn, mastodont_t* api, char** data)
|
||||
|
@ -777,7 +778,8 @@ void content_account_muted(struct session* ssn, mastodont_t* api, char** data)
|
|||
|
||||
mastodont_get_mutes(api, &m_args, &args, &storage, &accts, &accts_len);
|
||||
|
||||
accounts_page(api, ssn, &storage, "Muted users", accts, accts_len);
|
||||
accounts_page(api, ssn, &storage, "Muted users", accts, accts_len);
|
||||
mstdnt_cleanup_accounts(accts, accts_len);
|
||||
}
|
||||
|
||||
void content_account_favourites(struct session* ssn, mastodont_t* api, char** data)
|
||||
|
|
|
@ -130,4 +130,5 @@ void list_edit(struct session* ssn, mastodont_t* api, char** data)
|
|||
NULL);
|
||||
|
||||
redirect(REDIRECT_303, referer);
|
||||
mastodont_storage_cleanup(&storage);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ char* reply_status(struct session* ssn, char* id, struct mstdnt_status* status)
|
|||
// Replies
|
||||
size_t replies_size = 0, replies_size_orig;
|
||||
char* replies = NULL;
|
||||
char* instance_domain = malloc(sizeof(config_instance_url)-1);
|
||||
char* instance_domain = malloc(sizeof(config_instance_url)+sizeof("https:///")+1);
|
||||
|
||||
// sscanf instead of regex works here and requires less work, we just need to trim off the slash at the end
|
||||
if (sscanf(config_instance_url, "https://%s/", instance_domain) == 0)
|
||||
|
@ -85,7 +85,7 @@ char* reply_status(struct session* ssn, char* id, struct mstdnt_status* status)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
instance_domain[strlen(instance_domain)-1] = '\0';
|
||||
instance_domain[strlen(instance_domain)] = '\0';
|
||||
// Remove ports, if any. Needed for development or if
|
||||
// the server actually supports these
|
||||
char* port_val = strchr(instance_domain, ':');
|
||||
|
|
18
src/status.c
18
src/status.c
|
@ -693,6 +693,9 @@ char* construct_status(struct session* ssn,
|
|||
NULL);
|
||||
mastodont_storage_cleanup(&reblogs_storage);
|
||||
mastodont_storage_cleanup(&favourites_storage);
|
||||
|
||||
mstdnt_cleanup_accounts(favourites, favourites_len);
|
||||
mstdnt_cleanup_accounts(reblogs, reblogs_len);
|
||||
}
|
||||
|
||||
// Repoint value if it's a reblog
|
||||
|
@ -809,6 +812,7 @@ char* construct_status(struct session* ssn,
|
|||
free(emoji_reactions);
|
||||
if (notif) free(notif_info);
|
||||
free(delete_status);
|
||||
free(pin_status);
|
||||
free(interactions_html);
|
||||
if (parse_content != status->content)
|
||||
free(parse_content);
|
||||
|
@ -881,26 +885,27 @@ void status_view_reblogs(struct session* ssn, mastodont_t* api, char** data)
|
|||
{
|
||||
struct mstdnt_args m_args;
|
||||
set_mstdnt_args(&m_args, ssn);
|
||||
struct mstdnt_account* favourites = NULL;
|
||||
struct mstdnt_account* reblogs = NULL;
|
||||
struct mstdnt_storage storage = { 0 };
|
||||
size_t favourites_len = 0;
|
||||
size_t reblogs_len = 0;
|
||||
char* status_id = data[0];
|
||||
|
||||
mastodont_status_reblogged_by(api,
|
||||
&m_args,
|
||||
status_id,
|
||||
&storage,
|
||||
&favourites,
|
||||
&favourites_len);
|
||||
&reblogs,
|
||||
&reblogs_len);
|
||||
|
||||
content_status_interactions(
|
||||
ssn,
|
||||
api,
|
||||
"Reblogs",
|
||||
favourites,
|
||||
favourites_len);
|
||||
reblogs,
|
||||
reblogs_len);
|
||||
|
||||
mastodont_storage_cleanup(&storage);
|
||||
mstdnt_cleanup_accounts(reblogs, reblogs_len);
|
||||
}
|
||||
|
||||
void status_view_favourites(struct session* ssn, mastodont_t* api, char** data)
|
||||
|
@ -927,6 +932,7 @@ void status_view_favourites(struct session* ssn, mastodont_t* api, char** data)
|
|||
favourites_len);
|
||||
|
||||
mastodont_storage_cleanup(&storage);
|
||||
mstdnt_cleanup_accounts(favourites, favourites_len);
|
||||
}
|
||||
|
||||
void content_status_interactions(struct session* ssn,
|
||||
|
|
|
@ -112,6 +112,7 @@ void content_timeline(struct session* ssn,
|
|||
mstdnt_cleanup_statuses(statuses, statuses_len);
|
||||
free(status_format);
|
||||
free(post_box);
|
||||
free(header);
|
||||
free(timeline_options);
|
||||
free(navigation_box);
|
||||
free(output);
|
||||
|
|
Loading…
Reference in a new issue