ref: b8d0e8f2692a2e0809d72cd621159e4ed4a6051d
parent: 7029129c4b7f1256bf5923b78c39537aa60267bf
author: graveolens <ktdill@gmail.com>
date: Fri Apr 4 13:02:53 EDT 2025
fix for remote_url returning nil crashes program
--- a/masto9.c
+++ b/masto9.c
@@ -71,7 +71,7 @@
{
JSON *obj, *id, *content, *reblogcontent, *account, *reblogaccount, *handle,
*rebloghandle, *displayname, *avatar, *reblog, *mediaattachments, *type,
- *previewurl, *remoteurl;
+ *previewurl, *remoteurl, *baseurl;
char *endpoint;
int i = 0;
@@ -127,12 +127,15 @@
type = getjsonkey(attachmentjson, "type");
previewurl = getjsonkey(attachmentjson, "preview_url");
remoteurl = getjsonkey(attachmentjson, "remote_url");
+ baseurl = getjsonkey(attachmentjson, "url");
attachment->type = estrdup((char *)type->s);
if(strcmp(type->s, "image") == 0) {
attachment->url = estrdup((char *)previewurl->s);
- } else {
+ } else if(remoteurl->s != 0) {
attachment->url = estrdup((char *)remoteurl->s);
+ } else {
+ attachment->url = estrdup((char*)baseurl->s);
}
toot->mediaattachments[j] = attachment;