mshow: extract_mime: fix logic to not free filename pointing to auto var

Found by clang-analyzer.
pull/1/merge
Christian Neukirchen 8 years ago
parent 1547d2a0e2
commit 396f1ed8df

@ -387,13 +387,16 @@ extract_mime(int depth, struct message *msg, char *body, size_t bodylen)
fwrite(body, 1, bodylen, stdout); fwrite(body, 1, bodylen, stdout);
} else { } else {
char buf[255]; char buf[255];
if (!filename) { char *bufptr;
if (filename) {
bufptr = filename;
} else {
snprintf(buf, sizeof buf, snprintf(buf, sizeof buf,
"attachment%d", mimecount); "attachment%d", mimecount);
filename = buf; bufptr = buf;
} }
printf("%s\n", filename); printf("%s\n", bufptr);
writefile(filename, body, bodylen); writefile(bufptr, body, bodylen);
} }
} else if (filename && strcmp(a, filename) == 0) { } else if (filename && strcmp(a, filename) == 0) {
// extract by name // extract by name

Loading…
Cancel
Save