Browse code

fix error path memory leaks (thanks to acab and njh) CVr: ----------------------------------------------------------------------

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@791 77e5149b-7576-45b1-b177-96237e5ba77b

Trog authored on 2004/08/25 19:08:26
Showing 2 changed files
... ...
@@ -1,4 +1,10 @@
1
+Wed Aug 25 11:06:42 BST 2004 (trog)
2
+-----------------------------------
3
+  * libclamac/ole2_extract.c: fix error path memory leaks
4
+	(thanks to acab and njh)
5
+
1 6
 Wed Aug 25 10:13:43 CEST 2004 (acab)
7
+------------------------------------
2 8
   * libclamav/petite.c: memory leaks fixed
3 9
 
4 10
 Tue Aug 24 13:47:07 CEST 2004 (tk)
... ...
@@ -604,6 +604,8 @@ static int handler_writefile(int fd, ole2_header_t *hdr, property_t *prop, const
604 604
 
605 605
 	ofd = open(newname, O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU);
606 606
 	if (ofd < 0) {
607
+		cli_errmsg("ERROR: failed to create file: %s\n", newname);
608
+		free(newname);
607 609
 		return FALSE;
608 610
 	}
609 611
 	free(newname);
... ...
@@ -767,6 +769,11 @@ int cli_ole2_extract(int fd, const char *dirname, const struct cl_limits *limits
767 767
 	
768 768
 	if (strncmp(hdr.magic, magic_id, 8) != 0) {
769 769
 		cli_dbgmsg("OLE2 magic failed!\n");
770
+#ifdef HAVE_MMAP
771
+		if (hdr.m_area != NULL) {
772
+			munmap(hdr.m_area, hdr.m_length);
773
+		}
774
+#endif
770 775
 		return CL_EOLE2;
771 776
 	}
772 777