aboutsummaryrefslogtreecommitdiffstats
path: root/fetchmail.c
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2020-03-30 21:02:40 +0200
committerMatthias Andree <matthias.andree@gmx.de>2020-03-30 21:02:40 +0200
commit85e5a019496c1f5ef1ae0393f21470de7f0ff046 (patch)
tree8fbfc9a7dc63cf62179eb1ff7674449674bcd2e4 /fetchmail.c
parentd9021ba3978a61b8db96e6dc4616ccf64b33ca36 (diff)
downloadfetchmail-85e5a019496c1f5ef1ae0393f21470de7f0ff046.tar.gz
fetchmail-85e5a019496c1f5ef1ae0393f21470de7f0ff046.tar.bz2
fetchmail-85e5a019496c1f5ef1ae0393f21470de7f0ff046.zip
fetchmail.c Avoid double-free in optmerge()'s STRING_MERGE macro.
The memory leak free fix could try to double-free fields. Zero them out properly to avoid that.
Diffstat (limited to 'fetchmail.c')
-rw-r--r--fetchmail.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fetchmail.c b/fetchmail.c
index c74d553c..2ad62205 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -974,8 +974,8 @@ static void optmerge(struct query *h2, struct query *h1, int force)
list_merge(&h2->domainlist, &h1->domainlist, force);
list_merge(&h2->antispam, &h1->antispam, force);
-#define FLAG_MERGE(fld) do { if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld; } while (0)
-#define STRING_MERGE(fld) do { if (force ? !!h1->fld : !h2->fld) { if (h2->fld) free((void *)h2->fld); h2->fld = h1->fld; } } while (0)
+#define FLAG_MERGE(fld) do { if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld; } while (0)
+#define STRING_MERGE(fld) do { if (force ? !!h1->fld : !h2->fld) { if (h2->fld) free((void *)h2->fld), h2->fld = 0; if (h1->fld) h2->fld = xstrdup(h1->fld); } } while (0)
STRING_MERGE(server.via);
FLAG_MERGE(server.protocol);
STRING_MERGE(server.service);