about summary refs log tree commit diff
path: root/mshow.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-21 20:26:37 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-21 20:26:37 +0200
commit396f1ed8dfbadda21c592bd49abdff671e03083c (patch)
tree41298eb5fe220e789c4567eaf5dded1ed6eb2fbe /mshow.c
parent1547d2a0e2335b7d11e2b8c674913636b7dc28e0 (diff)
downloadmblaze-396f1ed8dfbadda21c592bd49abdff671e03083c.tar.gz
mblaze-396f1ed8dfbadda21c592bd49abdff671e03083c.tar.xz
mblaze-396f1ed8dfbadda21c592bd49abdff671e03083c.zip
mshow: extract_mime: fix logic to not free filename pointing to auto var
Found by clang-analyzer.
Diffstat (limited to 'mshow.c')
-rw-r--r--mshow.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mshow.c b/mshow.c
index 8cab666..48e4a2a 100644
--- a/mshow.c
+++ b/mshow.c
@@ -387,13 +387,16 @@ extract_mime(int depth, struct message *msg, char *body, size_t bodylen)
 					fwrite(body, 1, bodylen, stdout);
 				} else {
 					char buf[255];
-					if (!filename) {
+					char *bufptr;
+					if (filename) {
+						bufptr = filename;
+					} else {
 						snprintf(buf, sizeof buf,
 						    "attachment%d", mimecount);
-						filename = buf;
+						bufptr = buf;
 					}
-					printf("%s\n", filename);
-					writefile(filename, body, bodylen);
+					printf("%s\n", bufptr);
+					writefile(bufptr, body, bodylen);
 				}
 			} else if (filename && strcmp(a, filename) == 0) {
 				// extract by name