From f1d7ee1609f27db719b61c3a9a2e4a0c2434b301 Mon Sep 17 00:00:00 2001 From: Julia Schroeder Date: Wed, 21 Aug 2024 09:36:49 +0200 Subject: [PATCH] ews: fix std::optional access before initialization References: GXH-102, GXF-1734 --- exch/ews/requests.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/exch/ews/requests.cpp b/exch/ews/requests.cpp index 26aac0a10..caadde8c5 100644 --- a/exch/ews/requests.cpp +++ b/exch/ews/requests.cpp @@ -234,15 +234,13 @@ void process(mCreateItemRequest&& request, XMLElement* response, const EWSContex mCreateItemResponse data; - bool hasAccess = true; std::optional targetFolder; if(request.SavedItemFolderId) targetFolder = ctx.resolveFolder(request.SavedItemFolderId->folderId); - std::string dir = ctx.getDir(*targetFolder); - if(!targetFolder) - targetFolder = ctx.resolveFolder(tDistinguishedFolderId("outbox")); else - hasAccess = ctx.permissions(dir, targetFolder->folderId) & (frightsOwner | frightsCreate); + targetFolder = ctx.resolveFolder(tDistinguishedFolderId("outbox")); + std::string dir = ctx.getDir(*targetFolder); + bool hasAccess = ctx.permissions(dir, targetFolder->folderId) & (frightsOwner | frightsCreate); if(!request.MessageDisposition) request.MessageDisposition = Enum::SaveOnly;