[Commits] [SCM] claws branch, master, updated. 3.18.0-170-g7ff8e070e
wwp at claws-mail.org
wwp at claws-mail.org
Sun Sep 26 21:27:10 CEST 2021
The branch, master has been updated
via 7ff8e070e8ff18454cc316353ba793858361a064 (commit)
from fa5ad28e7bdb9bb254254480dad839fe73313d99 (commit)
Summary of changes:
src/procmime.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 7ff8e070e8ff18454cc316353ba793858361a064
Author: wwp <subscript at free.fr>
Date: Sun Sep 26 21:26:58 2021 +0200
Fix CID 1491065, 1491075 and 1491274: resource leaks
diff --git a/src/procmime.c b/src/procmime.c
index b2c33c453..c79e62d01 100644
--- a/src/procmime.c
+++ b/src/procmime.c
@@ -347,6 +347,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
if (!outfp) {
perror("tmpfile");
claws_fclose(infp);
+ g_free(tmpfilename);
return FALSE;
}
@@ -483,6 +484,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
if (g_stat(tmpfilename, &statbuf) < 0) {
FILE_OP_ERROR(tmpfilename, "stat");
+ g_free(tmpfilename);
return FALSE;
}
@@ -522,22 +524,26 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
outfp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
if (!outfp) {
perror("tmpfile");
+ g_free(tmpfilename);
return FALSE;
}
if (mimeinfo->content == MIMECONTENT_FILE && mimeinfo->data.filename) {
if ((infp = claws_fopen(mimeinfo->data.filename, "rb")) == NULL) {
g_warning("can't open file %s", mimeinfo->data.filename);
+ g_free(tmpfilename);
claws_fclose(outfp);
return FALSE;
}
} else if (mimeinfo->content == MIMECONTENT_MEM) {
infp = str_open_as_stream(mimeinfo->data.mem);
if (infp == NULL) {
+ g_free(tmpfilename);
claws_fclose(outfp);
return FALSE;
}
} else {
+ g_free(tmpfilename);
claws_fclose(outfp);
g_warning("unknown mimeinfo");
return FALSE;
@@ -554,6 +560,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
tmp_file = get_tmp_file();
if (canonicalize_file(mimeinfo->data.filename, tmp_file) < 0) {
g_free(tmp_file);
+ g_free(tmpfilename);
claws_fclose(infp);
claws_fclose(outfp);
return FALSE;
@@ -562,6 +569,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
FILE_OP_ERROR(tmp_file, "claws_fopen");
claws_unlink(tmp_file);
g_free(tmp_file);
+ g_free(tmpfilename);
claws_fclose(infp);
claws_fclose(outfp);
return FALSE;
@@ -573,6 +581,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
tmp_fp = infp;
g_free(out);
if (infp == NULL) {
+ g_free(tmpfilename);
claws_fclose(outfp);
return FALSE;
}
@@ -636,9 +645,11 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
claws_fclose(outfp);
claws_fclose(infp);
- if (err == TRUE)
+ if (err == TRUE) {
+ g_free(tmpfilename);
return FALSE;
-
+ }
+
if (mimeinfo->content == MIMECONTENT_FILE) {
if (mimeinfo->tmp && (mimeinfo->data.filename != NULL))
claws_unlink(mimeinfo->data.filename);
@@ -650,6 +661,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
if (g_stat(tmpfilename, &statbuf) < 0) {
FILE_OP_ERROR(tmpfilename, "stat");
+ g_free(tmpfilename);
return FALSE;
}
mimeinfo->content = MIMECONTENT_FILE;
@@ -1026,8 +1038,10 @@ gchar *procmime_get_tmp_file_name(MimeInfo *mimeinfo)
if (basetmp == NULL)
basetmp = "mimetmp";
basetmp = g_path_get_basename(basetmp);
- if (*basetmp == '\0')
+ if (*basetmp == '\0') {
+ g_free(basetmp);
basetmp = g_strdup("mimetmp");
+ }
base = conv_filename_from_utf8(basetmp);
g_free((gchar*)basetmp);
subst_for_shellsafe_filename(base);
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list