Fix memleak and buffer overflow

FossilOrigin-Name: a5eca2f8f968f09ca712de322a11da6e5a9ce0d92af640e0ec80685c59dba8fd
This commit is contained in:
nekobit 2022-05-13 03:57:11 +00:00
parent 68bbd48da6
commit 1960500550
2 changed files with 8 additions and 6 deletions

View file

@ -122,14 +122,16 @@ breakpt:
path_info->callback(ssn, api, data);
}
else
{
res = 1;
}
// Cleanup
for (size_t i = 0; i < size; ++i)
{
free(data[i]);
}
if (data) free(data);
/* for (size_t i = 0; i < size; ++i) */
/* { */
/* free(data[i]); */
/* } */
/* if (data) free(data); */
return res;
}

View file

@ -117,7 +117,7 @@ char* reply_status(char* id, struct mstdnt_status* status)
replies[replies_size-1] = ' ';
}
replies[replies_size] = '\0';
replies[replies_size-1] = '\0';
stat_reply = construct_post_box(id, replies, NULL);
if (replies) free(replies);