From 19605005507d35bee684176ca01b60dd79a0bdba Mon Sep 17 00:00:00 2001 From: nekobit Date: Fri, 13 May 2022 03:57:11 +0000 Subject: [PATCH] Fix memleak and buffer overflow FossilOrigin-Name: a5eca2f8f968f09ca712de322a11da6e5a9ce0d92af640e0ec80685c59dba8fd --- src/path.c | 12 +++++++----- src/reply.c | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/path.c b/src/path.c index 5be0337..ed4af0c 100644 --- a/src/path.c +++ b/src/path.c @@ -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; } diff --git a/src/reply.c b/src/reply.c index dd3a1d9..7d67b9e 100644 --- a/src/reply.c +++ b/src/reply.c @@ -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);