validate_recipients() remove extra copy of recipients
[citadel.git] / citadel / server / internet_addressing.c
index b08123143c647ea2c95448422cb4dc075288241f..0bc7507043ca955a99fbfe271a076cf35e294641 100644 (file)
@@ -3,8 +3,7 @@
 //
 // Copyright (c) 1987-2024 by the citadel.org team
 //
-// This program is open source software.  Use, duplication, or disclosure
-// is subject to the terms of the GNU General Public License, version 3.
+// This program is open source software.  Use, duplication, or disclosure is subject to the GNU General Public License version 3.
 
 #include "sysdep.h"
 #include <stdlib.h>
@@ -296,9 +295,8 @@ Array *split_recps(char *addresses, Array *append_to) {
 //
 // Caller needs to free the result using free_recipients()
 //
-struct recptypes *validate_recipients(char *supplied_recipients, const char *RemoteIdentifier, int Flags) {
+struct recptypes *validate_recipients(char *recipients_in, const char *REMOVE_THIS_UNUSED_VARIABLE, int Flags) {
        struct recptypes *ret;
-       char *recipients = NULL;
        char append[SIZ];
        long len;
        int mailtype;
@@ -314,14 +312,7 @@ struct recptypes *validate_recipients(char *supplied_recipients, const char *Rem
        if (ret == NULL) return(NULL);
        memset(ret, 0, sizeof(struct recptypes));                                       // set all values to null/zero
 
-       if (supplied_recipients == NULL) {
-               recipients = strdup("");
-       }
-       else {
-               recipients = strdup(supplied_recipients);
-       }
-
-       len = strlen(recipients) + 1024;                                                // allocate memory
+       len = strlen(recipients_in) + 1024;                                             // allocate memory
        ret->errormsg = malloc(len);
        ret->recp_local = malloc(len);
        ret->recp_internet = malloc(len);
@@ -337,7 +328,7 @@ struct recptypes *validate_recipients(char *supplied_recipients, const char *Rem
        ret->display_recp[0] = 0;
        ret->recptypes_magic = RECPTYPES_MAGIC;
 
-       Array *recp_array = split_recps(supplied_recipients, NULL);
+       Array *recp_array = split_recps(recipients_in, NULL);
 
        char *aliases = CtdlGetSysConfig(GLOBAL_ALIASES);                               // First hit the Global Alias Table
 
@@ -509,7 +500,6 @@ struct recptypes *validate_recipients(char *supplied_recipients, const char *Rem
                ret->num_local, ret->num_room, ret->num_internet, ret->num_error
        );
 
-       free(recipients);
        if (recp_array) {
                array_free(recp_array);
        }
@@ -1069,7 +1059,7 @@ struct CtdlMessage *convert_internet_message_buf(StrBuf **rfc822) {
        if (pos < totalend)
                StrBufAppendBufPlain(OtherHeaders, pos, totalend - pos, 0);
        FreeStrBuf(rfc822);
-       CM_SetAsFieldSB(msg, eMesageText, &OtherHeaders);
+       CM_SetAsFieldSB(msg, eMessageText, &OtherHeaders);
 
        // Follow-up sanity checks...