63f1cdc
--- clamav-0.88.7/libclamav/htmlnorm.c.bz-582
63f1cdc
+++ clamav-0.88.7/libclamav/htmlnorm.c
63f1cdc
@@ -1042,33 +1042,37 @@ static int cli_html_normalise(int fd, m_
63f1cdc
 				}
63f1cdc
 				break;
63f1cdc
 			case HTML_RFC2397_INIT:
63f1cdc
-				file_tmp_o1 = (file_buff_t *) cli_malloc(sizeof(file_buff_t));
63f1cdc
-				if (!file_tmp_o1) {
63f1cdc
-					goto abort;
63f1cdc
-				}
63f1cdc
-				snprintf(filename, 1024, "%s/rfc2397", dirname);
63f1cdc
-				tmp_file = cli_gentemp(filename);
63f1cdc
-				cli_dbgmsg("RFC2397 data file: %s\n", tmp_file);
63f1cdc
-				file_tmp_o1->fd = open(tmp_file, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR);
63f1cdc
-				free(tmp_file);
63f1cdc
-				if (!file_tmp_o1->fd) {
63f1cdc
-					cli_dbgmsg("open failed: %s\n", filename);
63f1cdc
-					free(file_tmp_o1);
63f1cdc
-					goto abort;
63f1cdc
-				}
63f1cdc
-				file_tmp_o1->length = 0;
63f1cdc
+				if (dirname) {
63f1cdc
+					file_tmp_o1 = (file_buff_t *) cli_malloc(sizeof(file_buff_t));
63f1cdc
+					if (!file_tmp_o1) {
63f1cdc
+						goto abort;
63f1cdc
+					}
63f1cdc
+					snprintf(filename, 1024, "%s/rfc2397", dirname);
63f1cdc
+					tmp_file = cli_gentemp(filename);
63f1cdc
+					cli_dbgmsg("RFC2397 data file: %s\n", tmp_file);
63f1cdc
+					file_tmp_o1->fd = open(tmp_file, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR);
63f1cdc
+					free(tmp_file);
63f1cdc
+					if (!file_tmp_o1->fd) {
63f1cdc
+						cli_dbgmsg("open failed: %s\n", filename);
63f1cdc
+						free(file_tmp_o1);
63f1cdc
+						goto abort;
63f1cdc
+					}
63f1cdc
+					file_tmp_o1->length = 0;
63f1cdc
 				
63f1cdc
-				html_output_str(file_tmp_o1, "From html-normalise\n", 20);
63f1cdc
-				html_output_str(file_tmp_o1, "Content-type: ", 14);
63f1cdc
-				if ((tag_val_length == 0) && (*tag_val == ';')) {
63f1cdc
+					html_output_str(file_tmp_o1, "From html-normalise\n", 20);
63f1cdc
+					html_output_str(file_tmp_o1, "Content-type: ", 14);
63f1cdc
+					if ((tag_val_length == 0) && (*tag_val == ';')) {
63f1cdc
 						html_output_str(file_tmp_o1, "text/plain\n", 11);
63f1cdc
+					}
63f1cdc
+					html_output_str(file_tmp_o1, tag_val, tag_val_length);
63f1cdc
+					html_output_c(file_tmp_o1, NULL, '\n');
63f1cdc
+					if (strstr(tag_val, ";base64") != NULL) {
63f1cdc
+						html_output_str(file_tmp_o1, "Content-transfer-encoding: base64\n", 34);
63f1cdc
+					}
63f1cdc
+					html_output_c(file_tmp_o1, NULL, '\n');
63f1cdc
+				} else {
63f1cdc
+					file_tmp_o1 = NULL;
63f1cdc
 				}
63f1cdc
-				html_output_str(file_tmp_o1, tag_val, tag_val_length);
63f1cdc
-				html_output_c(file_tmp_o1, NULL, '\n');
63f1cdc
-				if (strstr(tag_val, ";base64") != NULL) {
63f1cdc
-					html_output_str(file_tmp_o1, "Content-transfer-encoding: base64\n", 34);
63f1cdc
-				}
63f1cdc
-				html_output_c(file_tmp_o1, NULL, '\n');
63f1cdc
 				state = HTML_RFC2397_DATA;
63f1cdc
 				binary = TRUE;
63f1cdc
 				break;
63f1cdc
@@ -1118,9 +1122,11 @@ static int cli_html_normalise(int fd, m_
63f1cdc
 				}
63f1cdc
 				break;
63f1cdc
 			case HTML_RFC2397_FINISH:
63f1cdc
-				html_output_flush(file_tmp_o1);
63f1cdc
-				close(file_tmp_o1->fd);
63f1cdc
-				free(file_tmp_o1);
63f1cdc
+				if(file_tmp_o1) {
63f1cdc
+					html_output_flush(file_tmp_o1);
63f1cdc
+					close(file_tmp_o1->fd);
63f1cdc
+					free(file_tmp_o1);
63f1cdc
+				}
63f1cdc
 				state = HTML_SKIP_WS;
63f1cdc
 				escape = FALSE;
63f1cdc
 				quoted = NOT_QUOTED;