Browse code

Fix error path error leaks.

git-svn: trunk@1890

Trog authored on 2006/04/07 19:14:52
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Apr  7 11:13:29 BST 2006 (trog)
2
+-----------------------------------
3
+  * libclamav/unrar/unrar.c: Fix error path error leaks.
4
+		Patch from Andrey J. Melnikoff.
5
+
1 6
 Thu Apr  6 19:39:36 CEST 2006 (tk)
2 7
 ----------------------------------
3 8
   * libclamav/zziplib/zzip-zip.c: add missing #include "others.h"
... ...
@@ -1345,6 +1345,10 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l
1345 1345
 	
1346 1346
 	main_hdr = read_header(fd, MAIN_HEAD);
1347 1347
 	if (!main_hdr) {
1348
+		ppm_destructor(&unpack_data->ppm_data);
1349
+		init_filters(unpack_data);
1350
+		unpack_free_data(unpack_data);
1351
+		free(unpack_data);
1348 1352
 		return metadata;
1349 1353
 	}
1350 1354
 	cli_dbgmsg("Head CRC: %.4x\n", main_hdr->head_crc);
... ...
@@ -1355,16 +1359,28 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l
1355 1355
 		/* Part of a RAR VOLUME - Skip it */
1356 1356
 		cli_dbgmsg("RAR MUTIPART VOLUME - Skippng.\n");
1357 1357
 		free(main_hdr);
1358
+		ppm_destructor(&unpack_data->ppm_data);
1359
+		init_filters(unpack_data);
1360
+		unpack_free_data(unpack_data);
1361
+		free(unpack_data);
1358 1362
 		return metadata;
1359 1363
         }
1360 1364
 
1361 1365
 	if (main_hdr->head_size < SIZEOF_NEWMHD) {
1362 1366
 		free(main_hdr);
1367
+		ppm_destructor(&unpack_data->ppm_data);
1368
+		init_filters(unpack_data);
1369
+		unpack_free_data(unpack_data);
1370
+		free(unpack_data);
1363 1371
 		return metadata;
1364 1372
 	}
1365 1373
 	if (main_hdr->head_size > SIZEOF_NEWMHD) {
1366 1374
 		if (!lseek(fd, main_hdr->head_size - SIZEOF_NEWMHD, SEEK_CUR)) {
1367 1375
 			free(main_hdr);
1376
+			ppm_destructor(&unpack_data->ppm_data);
1377
+			init_filters(unpack_data);
1378
+			unpack_free_data(unpack_data);
1379
+			free(unpack_data);
1368 1380
 			return metadata;
1369 1381
 		}
1370 1382
 	}
... ...
@@ -1450,6 +1466,11 @@ rar_metadata_t *cli_unrar(int fd, const char *dirname, const struct cl_limits *l
1450 1450
 			cli_dbgmsg("ERROR: seek failed: %ld\n", file_header->next_offset);
1451 1451
 			free(file_header->filename);
1452 1452
 			free(file_header);
1453
+			free(main_hdr);
1454
+			ppm_destructor(&unpack_data->ppm_data);
1455
+			init_filters(unpack_data);
1456
+			unpack_free_data(unpack_data);
1457
+			free(unpack_data);
1453 1458
 			return metadata;
1454 1459
 		}
1455 1460
 		free(file_header->filename);