about summary refs log tree commit diff
path: root/mshow.c
diff options
context:
space:
mode:
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