X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/146835943204559707b5461859837cb51fd3485a..4e8e2c96547bfe72589982a85fac450df4cf6d08:/sbr/mime_type.c diff --git a/sbr/mime_type.c b/sbr/mime_type.c index be791096..e4f3e5b8 100644 --- a/sbr/mime_type.c +++ b/sbr/mime_type.c @@ -37,14 +37,15 @@ mime_type(const char *file_name) { if ((mimeencoding = get_file_info(MIMEENCODINGPROC, file_name))) { content_type = concat(mimetype, "; charset=", mimeencoding, NULL); + free (mimetype); } else { - content_type = strdup(mimetype); + content_type = mimetype; } } else { - content_type = strdup(mimetype); + content_type = mimetype; } #else /* MIMEENCODINGPROC */ - content_type = strdup(mimetype); + content_type = mimetype; #endif /* MIMEENCODINGPROC */ } #endif /* MIMETYPEPROC */ @@ -91,7 +92,7 @@ mime_type(const char *file_name) { } while ((c = getc(fp)) != EOF) { - if (! isascii(c)) { + if (! isascii(c) || c == 0) { binary = 1; break; } @@ -123,12 +124,10 @@ get_file_info(const char *proc, const char *file_name) { advise(NULL, "filenames containing both single and double quotes " "are unsupported for attachment"); return NULL; - } else { - quotec = "\""; } + quotec = "\""; } - cmd = concat(proc, " ", quotec, file_name, quotec, NULL); if ((cmd = concat(proc, " ", quotec, file_name, quotec, NULL))) { FILE *fp;