From 30c5bae8b3d251c1b5e6786398014d5a9aa35c76 Mon Sep 17 00:00:00 2001 From: nekobit Date: Fri, 13 May 2022 04:10:25 +0000 Subject: [PATCH] Fix invalid argument and free correctly FossilOrigin-Name: a695bf01ee6ac9214c0c024c7c4bdc8360ceb9e8034cefa619923eda7a30f997 --- src/notification.c | 1 - src/status.c | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/notification.c b/src/notification.c index 23dd896..67e7d2c 100644 --- a/src/notification.c +++ b/src/notification.c @@ -75,7 +75,6 @@ int mstdnt_notifications_json_callback(cJSON* json, void* _args) return mstdnt_notifications_json(args->notif, args->size, json); } - int mastodont_get_notifications(mastodont_t* data, struct mstdnt_get_notifications_args* args, struct mstdnt_storage* storage, diff --git a/src/status.c b/src/status.c index 758e57a..f06a141 100644 --- a/src/status.c +++ b/src/status.c @@ -49,6 +49,10 @@ int mstdnt_status_json(struct mstdnt_status* status, cJSON* js) { cJSON* v; + // Not an error + if (!(status && js)) + return 0; + /* Zero out */ memset(status, 0, sizeof(struct mstdnt_status)); @@ -474,7 +478,7 @@ int mastodont_status_emoji_react(mastodont_t* api, char* id, char* emoji, NULL, 0, NULL, 0, CURLOPT_PUT, - &status, + status, mstdnt_status_json_callback }; @@ -487,7 +491,10 @@ void mstdnt_cleanup_status(struct mstdnt_status* status) cleanup_status_pleroma(&(status->pleroma)); cleanup_emojis(status->emojis); if (status->reblog) + { + mstdnt_cleanup_status(status->reblog); free(status->reblog); + } } void mstdnt_cleanup_statuses(struct mstdnt_status* statuses, size_t s)