From 2c509d650c04fedbf2b151a8f7ae10b77c2a5504 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Tue, 29 Mar 2022 19:33:49 +0000 Subject: [PATCH] Check for error FossilOrigin-Name: f006d7df58bb3a566f956dddc2ae79493758b422afea5dee3da8982e15c2de4a --- src/json_helper.c | 2 +- src/request.c | 2 -- src/status.c | 3 +++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/json_helper.c b/src/json_helper.c index 50882fe..e6d5572 100644 --- a/src/json_helper.c +++ b/src/json_helper.c @@ -33,7 +33,7 @@ int _mstdnt_key_val_ref(cJSON* v, struct _mstdnt_val_ref* refs, size_t i; for (i = 0; i < refs_len; ++i) { - if (strcmp(refs[i].key, v->string) == 0) + if (v->string && strcmp(refs[i].key, v->string) == 0) { refs[i].handle(v, refs[i].val); return 0; diff --git a/src/request.c b/src/request.c index 68f0243..37d806d 100644 --- a/src/request.c +++ b/src/request.c @@ -42,13 +42,11 @@ int mastodont_request(mastodont_t* data, struct mastodont_request_args* args) goto cleanup; } - /* if (mstdnt_check_error(&results, storage)) { res = 1; goto cleanup_res; } - */ /* Optional */ if (args->callback) args->callback(&results, storage, args->args); diff --git a/src/status.c b/src/status.c index f6704fb..53f5c03 100644 --- a/src/status.c +++ b/src/status.c @@ -85,6 +85,9 @@ int mstdnt_status_from_result(struct mstdnt_fetch_results* results, struct mstdnt_storage* storage, struct mstdnt_status* status) { + /* Can be null sometimes */ + if (!status) return 0; + cJSON* root; if (_mstdnt_json_init(&root, results, storage) || !cJSON_IsObject(root))