summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-01-11 21:33:41 +0100
committerdefault <nobody@localhost>2024-01-11 21:33:41 +0100
commit5532a3e8bdec92ada01bd844f796f0f95e9e312e (patch)
treea5d3a1452683bf853ca49e5d076028b4b96c2765
parentadf5623044f7dcd84edb8345595a1bda651e5cbb (diff)
More tries to fix crashes in mastoapi_account().
-rw-r--r--mastoapi.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index d8f6ccc..d3221c1 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -494,7 +494,6 @@ xs_str *mastoapi_id(const xs_dict *msg)
xs_dict *mastoapi_account(const xs_dict *actor)
/* converts an ActivityPub actor to a Mastodon account */
{
- xs_dict *acct = xs_dict_new();
const char *prefu = xs_dict_get(actor, "preferredUsername");
const char *display_name = xs_dict_get(actor, "name");
@@ -503,7 +502,12 @@ xs_dict *mastoapi_account(const xs_dict *actor)
const char *id = xs_dict_get(actor, "id");
const char *pub = xs_dict_get(actor, "published");
- xs *acct_md5 = xs_md5_hex(id, strlen(id));
+
+ if (xs_is_null(id))
+ return NULL;
+
+ xs_dict *acct = xs_dict_new();
+ xs *acct_md5 = xs_md5_hex(id, strlen(id));
acct = xs_dict_append(acct, "id", acct_md5);
acct = xs_dict_append(acct, "username", prefu);
acct = xs_dict_append(acct, "display_name", display_name);
@@ -711,6 +715,8 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
return NULL;
xs *acct = mastoapi_account(actor);
+ if (acct == NULL)
+ return NULL;
xs *idx = NULL;
xs *ixc = NULL;