From ca47058e8c230e8da1a24d9f476e008c5d97ebdb Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 27 Jun 2023 17:17:32 +0200 Subject: [PATCH] [core,gateway] use custom copy for listdictionary --- libfreerdp/core/gateway/http.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libfreerdp/core/gateway/http.c b/libfreerdp/core/gateway/http.c index 21e8f0d78..cb952a2b8 100644 --- a/libfreerdp/core/gateway/http.c +++ b/libfreerdp/core/gateway/http.c @@ -131,6 +131,14 @@ static BOOL strings_equals_nocase(const void* obj1, const void* obj2) return _stricmp(obj1, obj2) == 0; } +static void* copy_string(const void* ptr) +{ + const char* str = ptr; + if (!str) + return NULL; + return _strdup(ptr); +} + HttpContext* http_context_new(void) { HttpContext* context = (HttpContext*)calloc(1, sizeof(HttpContext)); @@ -139,8 +147,8 @@ HttpContext* http_context_new(void) context->cookies = ListDictionary_New(FALSE); ListDictionary_KeyObject(context->cookies)->fnObjectFree = free; ListDictionary_ValueObject(context->cookies)->fnObjectFree = free; - ListDictionary_KeyObject(context->cookies)->fnObjectNew = _strdup; - ListDictionary_ValueObject(context->cookies)->fnObjectNew = _strdup; + ListDictionary_KeyObject(context->cookies)->fnObjectNew = copy_string; + ListDictionary_ValueObject(context->cookies)->fnObjectNew = copy_string; } return context; }