From a1a32d227a49d92e637d3311468cc53508e6e446 Mon Sep 17 00:00:00 2001 From: "Craig Edwards (Brain)" Date: Sat, 12 Oct 2024 13:37:27 +0100 Subject: [PATCH] fix: crash in threads_get_public_archived (#1268) --- src/dpp/thread.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dpp/thread.cpp b/src/dpp/thread.cpp index 8cfe5d618a..af661fe663 100644 --- a/src/dpp/thread.cpp +++ b/src/dpp/thread.cpp @@ -46,12 +46,14 @@ thread& thread::fill_from_json_impl(json* j) { set_int8_not_null(j, "member_count", this->member_count); set_bool_not_null(j, "newly_created", this->newly_created); - auto json_metadata = (*j)["thread_metadata"]; - metadata.archived = bool_not_null(&json_metadata, "archived"); - metadata.archive_timestamp = ts_not_null(&json_metadata, "archive_timestamp"); - metadata.auto_archive_duration = int16_not_null(&json_metadata, "auto_archive_duration"); - metadata.locked = bool_not_null(&json_metadata, "locked"); - metadata.invitable = bool_not_null(&json_metadata, "invitable"); + if (j->contains("thread_metadata")) { + auto json_metadata = (*j)["thread_metadata"]; + metadata.archived = bool_not_null(&json_metadata, "archived"); + metadata.archive_timestamp = ts_not_null(&json_metadata, "archive_timestamp"); + metadata.auto_archive_duration = int16_not_null(&json_metadata, "auto_archive_duration"); + metadata.locked = bool_not_null(&json_metadata, "locked"); + metadata.invitable = bool_not_null(&json_metadata, "invitable"); + } /* Only certain events set this */ if (j->contains("member")) {