diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-09-29 23:45:36 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-09-29 23:45:36 +0200 |
commit | affed6725ee58aa4dadb227d8033cc3a1dffa7e1 (patch) | |
tree | 1ad1530feeb9509c09b1ca8685ddfbd2b137e3d3 /lib | |
parent | 7f304ab84f560c9ddcd3ed1887bb4aa99a90bd6a (diff) |
smtp_mail: fix memory leak
... introduced in 7f304ab84f560c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/smtp.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/smtp.c b/lib/smtp.c index 68b05f208..dbfc589c5 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -795,22 +795,32 @@ static CURLcode smtp_mail(struct connectdata *conn) /* calculate the FROM parameter */ if(!data->set.str[STRING_MAIL_FROM]) /* null reverse-path, RFC-2821, sect. 3.7 */ - from = "<>"; + from = strdup("<>"); else if(data->set.str[STRING_MAIL_FROM][0] == '<') from = aprintf("%s", data->set.str[STRING_MAIL_FROM]); else from = aprintf("<%s>", data->set.str[STRING_MAIL_FROM]); + if(!from) + return CURLE_OUT_OF_MEMORY; + /* calculate the optional SIZE parameter */ - if(conn->data->set.infilesize > 0) + if(conn->data->set.infilesize > 0) { size = aprintf("%" FORMAT_OFF_T, data->set.infilesize); + if(!size) + return CURLE_OUT_OF_MEMORY; + } + /* send MAIL FROM */ if(size == NULL) result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s", from); else result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s SIZE=%s", - from, size); + from, size); + + Curl_safefree(size); + Curl_safefree(from); if(result) return result; |