From 39ef05010989471738827a05995ec9ec1da5d755 Mon Sep 17 00:00:00 2001 From: lda Date: Sun, 3 Dec 2023 16:41:45 +0100 Subject: [PATCH] [FIX] Fix memory issue when creating a configuration --- src/Config.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Config.c b/src/Config.c index 210c5dc..63e7aca 100644 --- a/src/Config.c +++ b/src/Config.c @@ -136,6 +136,8 @@ ConfigCreateDefault(Db * db) config.registration = 0; config.federation = 1; + config.serverName = Malloc(HOST_NAME_MAX + 1); + memset(config.serverName, 0, HOST_NAME_MAX + 1); gethostname(config.serverName, HOST_NAME_MAX); len = strlen(config.serverName) + 10; config.baseUrl = Malloc(len); @@ -151,13 +153,6 @@ ConfigCreateDefault(Db * db) listener->tls.cert = NULL; ArrayAdd(config.listen, listener); - config.serverName = Malloc(HOST_NAME_MAX + 1); - - /* TODO: Don't set that field(it has to because otherwise j2s will add - * a NULL byte it seems.) */ - config.identityServer = StrDuplicate(""); - - json = ConfigToJson(&config); ref = DbCreate(db, 1, "config");