]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/lists.c
Fix 8ec17063: "Lists_Add(): use size of destination when copying data"
[ngircd-alex.git] / src / ngircd / lists.c
index 45a4874b6e94f268aa2a0942cdf249c4aec12a24..5c6c52c4c9b2c9f15a4bdddcd05bef422125b929 100644 (file)
@@ -147,11 +147,8 @@ Lists_Add(struct list_head *h, const char *Mask, time_t ValidUntil,
 
        strlcpy(newelem->mask, Mask, sizeof(newelem->mask));
        if (Reason) {
-               newelem->reason = malloc(strlen(Reason) + 1);
-               if (newelem->reason)
-                       strlcpy(newelem->reason, Reason,
-                               sizeof(newelem->reason));
-               else
+               newelem->reason = strdup(Reason);
+               if (!newelem->reason)
                        Log(LOG_EMERG,
                            "Can't allocate memory for new list reason text!");
        }